1" Vim support file to detect file types 2" 3" Maintainer: Bram Moolenaar <[email protected]> 4" Last Change: 2014 Oct 09 5 6" Listen very carefully, I will say this only once 7if exists("did_load_filetypes") 8 finish 9endif 10let did_load_filetypes = 1 11 12" Line continuation is used here, remove 'C' from 'cpoptions' 13let s:cpo_save = &cpo 14set cpo&vim 15 16augroup filetypedetect 17 18" Ignored extensions 19if exists("*fnameescape") 20au BufNewFile,BufRead ?\+.orig,?\+.bak,?\+.old,?\+.new,?\+.dpkg-dist,?\+.dpkg-old,?\+.dpkg-new,?\+.dpkg-bak,?\+.rpmsave,?\+.rpmnew 21 \ exe "doau filetypedetect BufRead " . fnameescape(expand("<afile>:r")) 22au BufNewFile,BufRead *~ 23 \ let s:name = expand("<afile>") | 24 \ let s:short = substitute(s:name, '\~$', '', '') | 25 \ if s:name != s:short && s:short != "" | 26 \ exe "doau filetypedetect BufRead " . fnameescape(s:short) | 27 \ endif | 28 \ unlet! s:name s:short 29au BufNewFile,BufRead ?\+.in 30 \ if expand("<afile>:t") != "configure.in" | 31 \ exe "doau filetypedetect BufRead " . fnameescape(expand("<afile>:r")) | 32 \ endif 33elseif &verbose > 0 34 echomsg "Warning: some filetypes will not be recognized because this version of Vim does not have fnameescape()" 35endif 36 37" Pattern used to match file names which should not be inspected. 38" Currently finds compressed files. 39if !exists("g:ft_ignore_pat") 40 let g:ft_ignore_pat = '\.\(Z\|gz\|bz2\|zip\|tgz\)$' 41endif 42 43" Function used for patterns that end in a star: don't set the filetype if the 44" file name matches ft_ignore_pat. 45func! s:StarSetf(ft) 46 if expand("<amatch>") !~ g:ft_ignore_pat 47 exe 'setf ' . a:ft 48 endif 49endfunc 50 51" Abaqus or Trasys 52au BufNewFile,BufRead *.inp call s:Check_inp() 53 54func! s:Check_inp() 55 if getline(1) =~ '^\*' 56 setf abaqus 57 else 58 let n = 1 59 if line("$") > 500 60 let nmax = 500 61 else 62 let nmax = line("$") 63 endif 64 while n <= nmax 65 if getline(n) =~? "^header surface data" 66 setf trasys 67 break 68 endif 69 let n = n + 1 70 endwhile 71 endif 72endfunc 73 74" A-A-P recipe 75au BufNewFile,BufRead *.aap setf aap 76 77" A2ps printing utility 78au BufNewFile,BufRead */etc/a2ps.cfg,*/etc/a2ps/*.cfg,a2psrc,.a2psrc setf a2ps 79 80" ABAB/4 81au BufNewFile,BufRead *.abap setf abap 82 83" ABC music notation 84au BufNewFile,BufRead *.abc setf abc 85 86" ABEL 87au BufNewFile,BufRead *.abl setf abel 88 89" AceDB 90au BufNewFile,BufRead *.wrm setf acedb 91 92" Ada (83, 9X, 95) 93au BufNewFile,BufRead *.adb,*.ads,*.ada setf ada 94if has("vms") 95 au BufNewFile,BufRead *.gpr,*.ada_m,*.adc setf ada 96else 97 au BufNewFile,BufRead *.gpr setf ada 98endif 99 100" AHDL 101au BufNewFile,BufRead *.tdf setf ahdl 102 103" AMPL 104au BufNewFile,BufRead *.run setf ampl 105 106" Ant 107au BufNewFile,BufRead build.xml setf ant 108 109" Arduino 110au BufNewFile,BufRead *.ino,*.pde setf arduino 111 112" Apache style config file 113au BufNewFile,BufRead proftpd.conf* call s:StarSetf('apachestyle') 114 115" Apache config file 116au BufNewFile,BufRead .htaccess,*/etc/httpd/*.conf setf apache 117 118" XA65 MOS6510 cross assembler 119au BufNewFile,BufRead *.a65 setf a65 120 121" Applescript 122au BufNewFile,BufRead *.scpt setf applescript 123 124" Applix ELF 125au BufNewFile,BufRead *.am 126 \ if expand("<afile>") !~? 'Makefile.am\>' | setf elf | endif 127 128" ALSA configuration 129au BufNewFile,BufRead .asoundrc,*/usr/share/alsa/alsa.conf,*/etc/asound.conf setf alsaconf 130 131" Arc Macro Language 132au BufNewFile,BufRead *.aml setf aml 133 134" APT config file 135au BufNewFile,BufRead apt.conf setf aptconf 136au BufNewFile,BufRead */.aptitude/config setf aptconf 137au BufNewFile,BufRead */etc/apt/apt.conf.d/{[-_[:alnum:]]\+,[-_.[:alnum:]]\+.conf} setf aptconf 138 139" Arch Inventory file 140au BufNewFile,BufRead .arch-inventory,=tagging-method setf arch 141 142" ART*Enterprise (formerly ART-IM) 143au BufNewFile,BufRead *.art setf art 144 145" AsciiDoc 146au BufNewFile,BufRead *.asciidoc setf asciidoc 147 148" ASN.1 149au BufNewFile,BufRead *.asn,*.asn1 setf asn 150 151" Active Server Pages (with Visual Basic Script) 152au BufNewFile,BufRead *.asa 153 \ if exists("g:filetype_asa") | 154 \ exe "setf " . g:filetype_asa | 155 \ else | 156 \ setf aspvbs | 157 \ endif 158 159" Active Server Pages (with Perl or Visual Basic Script) 160au BufNewFile,BufRead *.asp 161 \ if exists("g:filetype_asp") | 162 \ exe "setf " . g:filetype_asp | 163 \ elseif getline(1) . getline(2) . getline(3) =~? "perlscript" | 164 \ setf aspperl | 165 \ else | 166 \ setf aspvbs | 167 \ endif 168 169" Grub (must be before catch *.lst) 170au BufNewFile,BufRead */boot/grub/menu.lst,*/boot/grub/grub.conf,*/etc/grub.conf setf grub 171 172" Assembly (all kinds) 173" *.lst is not pure assembly, it has two extra columns (address, byte codes) 174au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst call s:FTasm() 175 176" This function checks for the kind of assembly that is wanted by the user, or 177" can be detected from the first five lines of the file. 178func! s:FTasm() 179 " make sure b:asmsyntax exists 180 if !exists("b:asmsyntax") 181 let b:asmsyntax = "" 182 endif 183 184 if b:asmsyntax == "" 185 call s:FTasmsyntax() 186 endif 187 188 " if b:asmsyntax still isn't set, default to asmsyntax or GNU 189 if b:asmsyntax == "" 190 if exists("g:asmsyntax") 191 let b:asmsyntax = g:asmsyntax 192 else 193 let b:asmsyntax = "asm" 194 endif 195 endif 196 197 exe "setf " . fnameescape(b:asmsyntax) 198endfunc 199 200func! s:FTasmsyntax() 201 " see if file contains any asmsyntax=foo overrides. If so, change 202 " b:asmsyntax appropriately 203 let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4). 204 \" ".getline(5)." " 205 let match = matchstr(head, '\sasmsyntax=\zs[a-zA-Z0-9]\+\ze\s') 206 if match != '' 207 let b:asmsyntax = match 208 elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library')) 209 let b:asmsyntax = "vmasm" 210 endif 211endfunc 212 213" Macro (VAX) 214au BufNewFile,BufRead *.mar setf vmasm 215 216" Atlas 217au BufNewFile,BufRead *.atl,*.as setf atlas 218 219" Autoit v3 220au BufNewFile,BufRead *.au3 setf autoit 221 222" Autohotkey 223au BufNewFile,BufRead *.ahk setf autohotkey 224 225" Automake 226au BufNewFile,BufRead [mM]akefile.am,GNUmakefile.am setf automake 227 228" Autotest .at files are actually m4 229au BufNewFile,BufRead *.at setf m4 230 231" Avenue 232au BufNewFile,BufRead *.ave setf ave 233 234" Awk 235au BufNewFile,BufRead *.awk setf awk 236 237" B 238au BufNewFile,BufRead *.mch,*.ref,*.imp setf b 239 240" BASIC or Visual Basic 241au BufNewFile,BufRead *.bas call s:FTVB("basic") 242 243" Check if one of the first five lines contains "VB_Name". In that case it is 244" probably a Visual Basic file. Otherwise it's assumed to be "alt" filetype. 245func! s:FTVB(alt) 246 if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)' 247 setf vb 248 else 249 exe "setf " . a:alt 250 endif 251endfunc 252 253" Visual Basic Script (close to Visual Basic) or Visual Basic .NET 254au BufNewFile,BufRead *.vb,*.vbs,*.dsm,*.ctl setf vb 255 256" IBasic file (similar to QBasic) 257au BufNewFile,BufRead *.iba,*.ibi setf ibasic 258 259" FreeBasic file (similar to QBasic) 260au BufNewFile,BufRead *.fb,*.bi setf freebasic 261 262" Batch file for MSDOS. 263au BufNewFile,BufRead *.bat,*.sys setf dosbatch 264" *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd. 265au BufNewFile,BufRead *.cmd 266 \ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif 267 268" Batch file for 4DOS 269au BufNewFile,BufRead *.btm call s:FTbtm() 270func! s:FTbtm() 271 if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm 272 setf dosbatch 273 else 274 setf btm 275 endif 276endfunc 277 278" BC calculator 279au BufNewFile,BufRead *.bc setf bc 280 281" BDF font 282au BufNewFile,BufRead *.bdf setf bdf 283 284" BibTeX bibliography database file 285au BufNewFile,BufRead *.bib setf bib 286 287" BibTeX Bibliography Style 288au BufNewFile,BufRead *.bst setf bst 289 290" BIND configuration 291au BufNewFile,BufRead named.conf,rndc.conf setf named 292 293" BIND zone 294au BufNewFile,BufRead named.root setf bindzone 295au BufNewFile,BufRead *.db call s:BindzoneCheck('') 296 297func! s:BindzoneCheck(default) 298 if getline(1).getline(2).getline(3).getline(4) =~ '^; <<>> DiG [0-9.]\+ <<>>\|BIND.*named\|$ORIGIN\|$TTL\|IN\s\+SOA' 299 setf bindzone 300 elseif a:default != '' 301 exe 'setf ' . a:default 302 endif 303endfunc 304 305" Blank 306au BufNewFile,BufRead *.bl setf blank 307 308" Blkid cache file 309au BufNewFile,BufRead */etc/blkid.tab,*/etc/blkid.tab.old setf xml 310 311" C or lpc 312au BufNewFile,BufRead *.c call s:FTlpc() 313 314func! s:FTlpc() 315 if exists("g:lpc_syntax_for_c") 316 let lnum = 1 317 while lnum <= 12 318 if getline(lnum) =~# '^\(//\|inherit\|private\|protected\|nosave\|string\|object\|mapping\|mixed\)' 319 setf lpc 320 return 321 endif 322 let lnum = lnum + 1 323 endwhile 324 endif 325 setf c 326endfunc 327 328" Calendar 329au BufNewFile,BufRead calendar setf calendar 330 331" C# 332au BufNewFile,BufRead *.cs setf cs 333 334" CSDL 335au BufNewFile,BufRead *.csdl setf csdl 336 337" Cabal 338au BufNewFile,BufRead *.cabal setf cabal 339 340" Cdrdao TOC 341au BufNewFile,BufRead *.toc setf cdrtoc 342 343" Cdrdao config 344au BufNewFile,BufRead */etc/cdrdao.conf,*/etc/defaults/cdrdao,*/etc/default/cdrdao,.cdrdao setf cdrdaoconf 345 346" Cfengine 347au BufNewFile,BufRead cfengine.conf setf cfengine 348 349" ChaiScript 350au BufRead,BufNewFile *.chai setf chaiscript 351 352" Comshare Dimension Definition Language 353au BufNewFile,BufRead *.cdl setf cdl 354 355" Conary Recipe 356au BufNewFile,BufRead *.recipe setf conaryrecipe 357 358" Controllable Regex Mutilator 359au BufNewFile,BufRead *.crm setf crm 360 361" Cyn++ 362au BufNewFile,BufRead *.cyn setf cynpp 363 364" Cynlib 365" .cc and .cpp files can be C++ or Cynlib. 366au BufNewFile,BufRead *.cc 367 \ if exists("cynlib_syntax_for_cc")|setf cynlib|else|setf cpp|endif 368au BufNewFile,BufRead *.cpp 369 \ if exists("cynlib_syntax_for_cpp")|setf cynlib|else|setf cpp|endif 370 371" C++ 372au BufNewFile,BufRead *.cxx,*.c++,*.hh,*.hxx,*.hpp,*.ipp,*.moc,*.tcc,*.inl setf cpp 373if has("fname_case") 374 au BufNewFile,BufRead *.C,*.H setf cpp 375endif 376 377" .h files can be C, Ch C++, ObjC or ObjC++. 378" Set c_syntax_for_h if you want C, ch_syntax_for_h if you want Ch. ObjC is 379" detected automatically. 380au BufNewFile,BufRead *.h call s:FTheader() 381 382func! s:FTheader() 383 if match(getline(1, min([line("$"), 200])), '^@\(interface\|end\|class\)') > -1 384 if exists("g:c_syntax_for_h") 385 setf objc 386 else 387 setf objcpp 388 endif 389 elseif exists("g:c_syntax_for_h") 390 setf c 391 elseif exists("g:ch_syntax_for_h") 392 setf ch 393 else 394 setf cpp 395 endif 396endfunc 397 398" Ch (CHscript) 399au BufNewFile,BufRead *.chf setf ch 400 401" TLH files are C++ headers generated by Visual C++'s #import from typelibs 402au BufNewFile,BufRead *.tlh setf cpp 403 404" Cascading Style Sheets 405au BufNewFile,BufRead *.css setf css 406 407" Century Term Command Scripts (*.cmd too) 408au BufNewFile,BufRead *.con setf cterm 409 410" Changelog 411au BufNewFile,BufRead changelog.Debian,changelog.dch,NEWS.Debian,NEWS.dch 412 \ setf debchangelog 413 414au BufNewFile,BufRead [cC]hange[lL]og 415 \ if getline(1) =~ '; urgency=' 416 \| setf debchangelog 417 \| else 418 \| setf changelog 419 \| endif 420 421au BufNewFile,BufRead NEWS 422 \ if getline(1) =~ '; urgency=' 423 \| setf debchangelog 424 \| endif 425 426" CHILL 427au BufNewFile,BufRead *..ch setf chill 428 429" Changes for WEB and CWEB or CHILL 430au BufNewFile,BufRead *.ch call s:FTchange() 431 432" This function checks if one of the first ten lines start with a '@'. In 433" that case it is probably a change file. 434" If the first line starts with # or ! it's probably a ch file. 435" If a line has "main", "include", "//" ir "/*" it's probably ch. 436" Otherwise CHILL is assumed. 437func! s:FTchange() 438 let lnum = 1 439 while lnum <= 10 440 if getline(lnum)[0] == '@' 441 setf change 442 return 443 endif 444 if lnum == 1 && (getline(1)[0] == '#' || getline(1)[0] == '!') 445 setf ch 446 return 447 endif 448 if getline(lnum) =~ "MODULE" 449 setf chill 450 return 451 endif 452 if getline(lnum) =~ 'main\s*(\|#\s*include\|//' 453 setf ch 454 return 455 endif 456 let lnum = lnum + 1 457 endwhile 458 setf chill 459endfunc 460 461" ChordPro 462au BufNewFile,BufRead *.chopro,*.crd,*.cho,*.crdpro,*.chordpro setf chordpro 463 464" Clean 465au BufNewFile,BufRead *.dcl,*.icl setf clean 466 467" Clever 468au BufNewFile,BufRead *.eni setf cl 469 470" Clever or dtd 471au BufNewFile,BufRead *.ent call s:FTent() 472 473func! s:FTent() 474 " This function checks for valid cl syntax in the first five lines. 475 " Look for either an opening comment, '#', or a block start, '{". 476 " If not found, assume SGML. 477 let lnum = 1 478 while lnum < 6 479 let line = getline(lnum) 480 if line =~ '^\s*[#{]' 481 setf cl 482 return 483 elseif line !~ '^\s*$' 484 " Not a blank line, not a comment, and not a block start, 485 " so doesn't look like valid cl code. 486 break 487 endif 488 let lnum = lnum + 1 489 endw 490 setf dtd 491endfunc 492 493" Clipper (or FoxPro; could also be eviews) 494au BufNewFile,BufRead *.prg 495 \ if exists("g:filetype_prg") | 496 \ exe "setf " . g:filetype_prg | 497 \ else | 498 \ setf clipper | 499 \ endif 500 501" Clojure 502au BufNewFile,BufRead *.clj,*.cljs setf clojure 503 504" Cmake 505au BufNewFile,BufRead CMakeLists.txt,*.cmake,*.cmake.in setf cmake 506 507" Cmusrc 508au BufNewFile,BufRead */.cmus/{autosave,rc,command-history,*.theme} setf cmusrc 509au BufNewFile,BufRead */cmus/{rc,*.theme} setf cmusrc 510 511" Cobol 512au BufNewFile,BufRead *.cbl,*.cob,*.lib setf cobol 513" cobol or zope form controller python script? (heuristic) 514au BufNewFile,BufRead *.cpy 515 \ if getline(1) =~ '^##' | 516 \ setf python | 517 \ else | 518 \ setf cobol | 519 \ endif 520 521" Coco/R 522au BufNewFile,BufRead *.atg setf coco 523 524" Cold Fusion 525au BufNewFile,BufRead *.cfm,*.cfi,*.cfc setf cf 526 527" Configure scripts 528au BufNewFile,BufRead configure.in,configure.ac setf config 529 530" CUDA Cumpute Unified Device Architecture 531au BufNewFile,BufRead *.cu setf cuda 532 533" Dockerfile 534au BufNewFile,BufRead Dockerfile setf dockerfile 535 536" WildPackets EtherPeek Decoder 537au BufNewFile,BufRead *.dcd setf dcd 538 539" Enlightenment configuration files 540au BufNewFile,BufRead *enlightenment/*.cfg setf c 541 542" Eterm 543au BufNewFile,BufRead *Eterm/*.cfg setf eterm 544 545" Euphoria 3 or 4 546au BufNewFile,BufRead *.eu,*.ew,*.ex,*.exu,*.exw call s:EuphoriaCheck() 547if has("fname_case") 548 au BufNewFile,BufRead *.EU,*.EW,*.EX,*.EXU,*.EXW call s:EuphoriaCheck() 549endif 550 551func! s:EuphoriaCheck() 552 if exists('g:filetype_euphoria') 553 exe 'setf ' . g:filetype_euphoria 554 else 555 setf euphoria3 556 endif 557endfunc 558 559" Lynx config files 560au BufNewFile,BufRead lynx.cfg setf lynx 561 562" Quake 563au BufNewFile,BufRead *baseq[2-3]/*.cfg,*id1/*.cfg setf quake 564au BufNewFile,BufRead *quake[1-3]/*.cfg setf quake 565 566" Quake C 567au BufNewFile,BufRead *.qc setf c 568 569" Configure files 570au BufNewFile,BufRead *.cfg setf cfg 571 572" Cucumber 573au BufNewFile,BufRead *.feature setf cucumber 574 575" Communicating Sequential Processes 576au BufNewFile,BufRead *.csp,*.fdr setf csp 577 578" CUPL logic description and simulation 579au BufNewFile,BufRead *.pld setf cupl 580au BufNewFile,BufRead *.si setf cuplsim 581 582" Debian Control 583au BufNewFile,BufRead */debian/control setf debcontrol 584au BufNewFile,BufRead control 585 \ if getline(1) =~ '^Source:' 586 \| setf debcontrol 587 \| endif 588 589" Debian Sources.list 590au BufNewFile,BufRead */etc/apt/sources.list setf debsources 591au BufNewFile,BufRead */etc/apt/sources.list.d/*.list setf debsources 592 593" Deny hosts 594au BufNewFile,BufRead denyhosts.conf setf denyhosts 595 596" dnsmasq(8) configuration files 597au BufNewFile,BufRead */etc/dnsmasq.conf setf dnsmasq 598 599" ROCKLinux package description 600au BufNewFile,BufRead *.desc setf desc 601 602" the D language or dtrace 603au BufNewFile,BufRead *.d call s:DtraceCheck() 604 605func! s:DtraceCheck() 606 let lines = getline(1, min([line("$"), 100])) 607 if match(lines, '^module\>\|^import\>') > -1 608 " D files often start with a module and/or import statement. 609 setf d 610 elseif match(lines, '^#!\S\+dtrace\|#pragma\s\+D\s\+option\|:\S\{-}:\S\{-}:') > -1 611 setf dtrace 612 else 613 setf d 614 endif 615endfunc 616 617" Desktop files 618au BufNewFile,BufRead *.desktop,.directory setf desktop 619 620" Dict config 621au BufNewFile,BufRead dict.conf,.dictrc setf dictconf 622 623" Dictd config 624au BufNewFile,BufRead dictd.conf setf dictdconf 625 626" Diff files 627au BufNewFile,BufRead *.diff,*.rej,*.patch setf diff 628 629" Dircolors 630au BufNewFile,BufRead .dir_colors,.dircolors,*/etc/DIR_COLORS setf dircolors 631 632" Diva (with Skill) or InstallShield 633au BufNewFile,BufRead *.rul 634 \ if getline(1).getline(2).getline(3).getline(4).getline(5).getline(6) =~? 'InstallShield' | 635 \ setf ishd | 636 \ else | 637 \ setf diva | 638 \ endif 639 640" DCL (Digital Command Language - vms) or DNS zone file 641au BufNewFile,BufRead *.com call s:BindzoneCheck('dcl') 642 643" DOT 644au BufNewFile,BufRead *.dot setf dot 645 646" Dylan - lid files 647au BufNewFile,BufRead *.lid setf dylanlid 648 649" Dylan - intr files (melange) 650au BufNewFile,BufRead *.intr setf dylanintr 651 652" Dylan 653au BufNewFile,BufRead *.dylan setf dylan 654 655" Microsoft Module Definition 656au BufNewFile,BufRead *.def setf def 657 658" Dracula 659au BufNewFile,BufRead *.drac,*.drc,*lvs,*lpe setf dracula 660 661" Datascript 662au BufNewFile,BufRead *.ds setf datascript 663 664" dsl 665au BufNewFile,BufRead *.dsl setf dsl 666 667" DTD (Document Type Definition for XML) 668au BufNewFile,BufRead *.dtd setf dtd 669 670" DTS/DSTI (device tree files) 671au BufNewFile,BufRead *.dts,*.dtsi setf dts 672 673" EDIF (*.edf,*.edif,*.edn,*.edo) 674au BufNewFile,BufRead *.ed\(f\|if\|n\|o\) setf edif 675 676" Embedix Component Description 677au BufNewFile,BufRead *.ecd setf ecd 678 679" Eiffel or Specman or Euphoria 680au BufNewFile,BufRead *.e,*.E call s:FTe() 681 682" Elinks configuration 683au BufNewFile,BufRead */etc/elinks.conf,*/.elinks/elinks.conf setf elinks 684 685func! s:FTe() 686 if exists('g:filetype_euphoria') 687 exe 'setf ' . g:filetype_euphoria 688 else 689 let n = 1 690 while n < 100 && n < line("$") 691 if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$" 692 setf specman 693 return 694 endif 695 let n = n + 1 696 endwhile 697 setf eiffel 698 endif 699endfunc 700 701" ERicsson LANGuage; Yaws is erlang too 702au BufNewFile,BufRead *.erl,*.hrl,*.yaws setf erlang 703 704" Elm Filter Rules file 705au BufNewFile,BufRead filter-rules setf elmfilt 706 707" ESMTP rc file 708au BufNewFile,BufRead *esmtprc setf esmtprc 709 710" ESQL-C 711au BufNewFile,BufRead *.ec,*.EC setf esqlc 712 713" Esterel 714au BufNewFile,BufRead *.strl setf esterel 715 716" Essbase script 717au BufNewFile,BufRead *.csc setf csc 718 719" Exim 720au BufNewFile,BufRead exim.conf setf exim 721 722" Expect 723au BufNewFile,BufRead *.exp setf expect 724 725" Exports 726au BufNewFile,BufRead exports setf exports 727 728" Falcon 729au BufNewFile,BufRead *.fal setf falcon 730 731" Fantom 732au BufNewFile,BufRead *.fan,*.fwt setf fan 733 734" Factor 735au BufNewFile,BufRead *.factor setf factor 736 737" Fetchmail RC file 738au BufNewFile,BufRead .fetchmailrc setf fetchmail 739 740" FlexWiki - disabled, because it has side effects when a .wiki file 741" is not actually FlexWiki 742"au BufNewFile,BufRead *.wiki setf flexwiki 743 744" Focus Executable 745au BufNewFile,BufRead *.fex,*.focexec setf focexec 746 747" Focus Master file (but not for auto.master) 748au BufNewFile,BufRead auto.master setf conf 749au BufNewFile,BufRead *.mas,*.master setf master 750 751" Forth 752au BufNewFile,BufRead *.fs,*.ft setf forth 753 754" Reva Forth 755au BufNewFile,BufRead *.frt setf reva 756 757" Fortran 758if has("fname_case") 759 au BufNewFile,BufRead *.F,*.FOR,*.FPP,*.FTN,*.F77,*.F90,*.F95,*.F03,*.F08 setf fortran 760endif 761au BufNewFile,BufRead *.f,*.for,*.fortran,*.fpp,*.ftn,*.f77,*.f90,*.f95,*.f03,*.f08 setf fortran 762 763" Framescript 764au BufNewFile,BufRead *.fsl setf framescript 765 766" FStab 767au BufNewFile,BufRead fstab,mtab setf fstab 768 769" GDB command files 770au BufNewFile,BufRead .gdbinit setf gdb 771 772" GDMO 773au BufNewFile,BufRead *.mo,*.gdmo setf gdmo 774 775" Gedcom 776au BufNewFile,BufRead *.ged,lltxxxxx.txt setf gedcom 777 778" Git 779au BufNewFile,BufRead *.git/COMMIT_EDITMSG setf gitcommit 780au BufNewFile,BufRead *.git/MERGE_MSG setf gitcommit 781au BufNewFile,BufRead *.git/config,.gitconfig,.gitmodules setf gitconfig 782au BufNewFile,BufRead *.git/modules/*/COMMIT_EDITMSG setf gitcommit 783au BufNewFile,BufRead *.git/modules/*/config setf gitconfig 784au BufNewFile,BufRead */.config/git/config setf gitconfig 785au BufNewFile,BufRead git-rebase-todo setf gitrebase 786au BufNewFile,BufRead .msg.[0-9]* 787 \ if getline(1) =~ '^From.*# This line is ignored.$' | 788 \ setf gitsendemail | 789 \ endif 790au BufNewFile,BufRead *.git/* 791 \ if getline(1) =~ '^\x\{40\}\>\|^ref: ' | 792 \ setf git | 793 \ endif 794 795" Gkrellmrc 796au BufNewFile,BufRead gkrellmrc,gkrellmrc_? setf gkrellmrc 797 798" GP scripts (2.0 and onward) 799au BufNewFile,BufRead *.gp,.gprc setf gp 800 801" GPG 802au BufNewFile,BufRead */.gnupg/options setf gpg 803au BufNewFile,BufRead */.gnupg/gpg.conf setf gpg 804au BufNewFile,BufRead */usr/*/gnupg/options.skel setf gpg 805 806" gnash(1) configuration files 807au BufNewFile,BufRead gnashrc,.gnashrc,gnashpluginrc,.gnashpluginrc setf gnash 808 809" Gitolite 810au BufNewFile,BufRead gitolite.conf setf gitolite 811au BufNewFile,BufRead */gitolite-admin/conf/* call s:StarSetf('gitolite') 812au BufNewFile,BufRead {,.}gitolite.rc,example.gitolite.rc setf perl 813 814" Gnuplot scripts 815au BufNewFile,BufRead *.gpi setf gnuplot 816 817" Go (Google) 818au BufNewFile,BufRead *.go setf go 819 820" GrADS scripts 821au BufNewFile,BufRead *.gs setf grads 822 823" Gretl 824au BufNewFile,BufRead *.gretl setf gretl 825 826" Groovy 827au BufNewFile,BufRead *.groovy setf groovy 828 829" GNU Server Pages 830au BufNewFile,BufRead *.gsp setf gsp 831 832" Group file 833au BufNewFile,BufRead */etc/group,*/etc/group-,*/etc/group.edit,*/etc/gshadow,*/etc/gshadow-,*/etc/gshadow.edit,*/var/backups/group.bak,*/var/backups/gshadow.bak setf group 834 835" GTK RC 836au BufNewFile,BufRead .gtkrc,gtkrc setf gtkrc 837 838" Haml 839au BufNewFile,BufRead *.haml setf haml 840 841" Hamster Classic | Playground files 842au BufNewFile,BufRead *.hsc,*.hsm setf hamster 843 844" Haskell 845au BufNewFile,BufRead *.hs,*.hs-boot setf haskell 846au BufNewFile,BufRead *.lhs setf lhaskell 847au BufNewFile,BufRead *.chs setf chaskell 848 849" Haste 850au BufNewFile,BufRead *.ht setf haste 851au BufNewFile,BufRead *.htpp setf hastepreproc 852 853" Hercules 854au BufNewFile,BufRead *.vc,*.ev,*.rs,*.sum,*.errsum setf hercules 855 856" HEX (Intel) 857au BufNewFile,BufRead *.hex,*.h32 setf hex 858 859" Tilde (must be before HTML) 860au BufNewFile,BufRead *.t.html setf tilde 861 862" HTML (.shtml and .stm for server side) 863au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm call s:FThtml() 864 865" Distinguish between HTML, XHTML and Django 866func! s:FThtml() 867 let n = 1 868 while n < 10 && n < line("$") 869 if getline(n) =~ '\<DTD\s\+XHTML\s' 870 setf xhtml 871 return 872 endif 873 if getline(n) =~ '{%\s*\(extends\|block\|load\)\>' 874 setf htmldjango 875 return 876 endif 877 let n = n + 1 878 endwhile 879 setf html 880endfunc 881 882" HTML with Ruby - eRuby 883au BufNewFile,BufRead *.erb,*.rhtml setf eruby 884 885" HTML with M4 886au BufNewFile,BufRead *.html.m4 setf htmlm4 887 888" HTML Cheetah template 889au BufNewFile,BufRead *.tmpl setf htmlcheetah 890 891" Host config 892au BufNewFile,BufRead */etc/host.conf setf hostconf 893 894" Hosts access 895au BufNewFile,BufRead */etc/hosts.allow,*/etc/hosts.deny setf hostsaccess 896 897" Hyper Builder 898au BufNewFile,BufRead *.hb setf hb 899 900" Httest 901au BufNewFile,BufRead *.htt,*.htb setf httest 902 903" Icon 904au BufNewFile,BufRead *.icn setf icon 905 906" IDL (Interface Description Language) 907au BufNewFile,BufRead *.idl call s:FTidl() 908 909" Distinguish between standard IDL and MS-IDL 910func! s:FTidl() 911 let n = 1 912 while n < 50 && n < line("$") 913 if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"' 914 setf msidl 915 return 916 endif 917 let n = n + 1 918 endwhile 919 setf idl 920endfunc 921 922" Microsoft IDL (Interface Description Language) Also *.idl 923" MOF = WMI (Windows Management Instrumentation) Managed Object Format 924au BufNewFile,BufRead *.odl,*.mof setf msidl 925 926" Icewm menu 927au BufNewFile,BufRead */.icewm/menu setf icemenu 928 929" Indent profile (must come before IDL *.pro!) 930au BufNewFile,BufRead .indent.pro setf indent 931au BufNewFile,BufRead indent.pro call s:ProtoCheck('indent') 932 933" IDL (Interactive Data Language) 934au BufNewFile,BufRead *.pro call s:ProtoCheck('idlang') 935 936" Distinguish between "default" and Cproto prototype file. */ 937func! s:ProtoCheck(default) 938 " Cproto files have a comment in the first line and a function prototype in 939 " the second line, it always ends in ";". Indent files may also have 940 " comments, thus we can't match comments to see the difference. 941 " IDL files can have a single ';' in the second line, require at least one 942 " chacter before the ';'. 943 if getline(2) =~ '.;$' 944 setf cpp 945 else 946 exe 'setf ' . a:default 947 endif 948endfunc 949 950 951" Indent RC 952au BufNewFile,BufRead indentrc setf indent 953 954" Inform 955au BufNewFile,BufRead *.inf,*.INF setf inform 956 957" Initng 958au BufNewFile,BufRead */etc/initng/*/*.i,*.ii setf initng 959 960" Innovation Data Processing 961au BufRead,BufNewFile upstream.dat\c,upstream.*.dat\c,*.upstream.dat\c setf upstreamdat 962au BufRead,BufNewFile upstream.log\c,upstream.*.log\c,*.upstream.log\c setf upstreamlog 963au BufRead,BufNewFile upstreaminstall.log\c,upstreaminstall.*.log\c,*.upstreaminstall.log\c setf upstreaminstalllog 964au BufRead,BufNewFile usserver.log\c,usserver.*.log\c,*.usserver.log\c setf usserverlog 965au BufRead,BufNewFile usw2kagt.log\c,usw2kagt.*.log\c,*.usw2kagt.log\c setf usw2kagtlog 966 967" Ipfilter 968au BufNewFile,BufRead ipf.conf,ipf6.conf,ipf.rules setf ipfilter 969 970" Informix 4GL (source - canonical, include file, I4GL+M4 preproc.) 971au BufNewFile,BufRead *.4gl,*.4gh,*.m4gl setf fgl 972 973" .INI file for MSDOS 974au BufNewFile,BufRead *.ini setf dosini 975 976" SysV Inittab 977au BufNewFile,BufRead inittab setf inittab 978 979" Inno Setup 980au BufNewFile,BufRead *.iss setf iss 981 982" J 983au BufNewFile,BufRead *.ijs setf j 984 985" JAL 986au BufNewFile,BufRead *.jal,*.JAL setf jal 987 988" Jam 989au BufNewFile,BufRead *.jpl,*.jpr setf jam 990 991" Java 992au BufNewFile,BufRead *.java,*.jav setf java 993 994" JavaCC 995au BufNewFile,BufRead *.jj,*.jjt setf javacc 996 997" JavaScript, ECMAScript 998au BufNewFile,BufRead *.js,*.javascript,*.es,*.jsx setf javascript 999 1000" Java Server Pages 1001au BufNewFile,BufRead *.jsp setf jsp 1002 1003" Java Properties resource file (note: doesn't catch font.properties.pl) 1004au BufNewFile,BufRead *.properties,*.properties_??,*.properties_??_?? setf jproperties 1005au BufNewFile,BufRead *.properties_??_??_* call s:StarSetf('jproperties') 1006 1007" Jess 1008au BufNewFile,BufRead *.clp setf jess 1009 1010" Jgraph 1011au BufNewFile,BufRead *.jgr setf jgraph 1012 1013" Jovial 1014au BufNewFile,BufRead *.jov,*.j73,*.jovial setf jovial 1015 1016" JSON 1017au BufNewFile,BufRead *.json,*.jsonp setf json 1018 1019" Kixtart 1020au BufNewFile,BufRead *.kix setf kix 1021 1022" Kimwitu[++] 1023au BufNewFile,BufRead *.k setf kwt 1024 1025" Kivy 1026au BufNewFile,BufRead *.kv setf kivy 1027 1028" KDE script 1029au BufNewFile,BufRead *.ks setf kscript 1030 1031" Kconfig 1032au BufNewFile,BufRead Kconfig,Kconfig.debug setf kconfig 1033 1034" Lace (ISE) 1035au BufNewFile,BufRead *.ace,*.ACE setf lace 1036 1037" Latte 1038au BufNewFile,BufRead *.latte,*.lte setf latte 1039 1040" Limits 1041au BufNewFile,BufRead */etc/limits,*/etc/*limits.conf,*/etc/*limits.d/*.conf setf limits 1042 1043" LambdaProlog (*.mod too, see Modsim) 1044au BufNewFile,BufRead *.sig setf lprolog 1045 1046" LDAP LDIF 1047au BufNewFile,BufRead *.ldif setf ldif 1048 1049" Ld loader 1050au BufNewFile,BufRead *.ld setf ld 1051 1052" Lex 1053au BufNewFile,BufRead *.lex,*.l,*.lxx,*.l++ setf lex 1054 1055" Libao 1056au BufNewFile,BufRead */etc/libao.conf,*/.libao setf libao 1057 1058" Libsensors 1059au BufNewFile,BufRead */etc/sensors.conf,*/etc/sensors3.conf setf sensors 1060 1061" LFTP 1062au BufNewFile,BufRead lftp.conf,.lftprc,*lftp/rc setf lftp 1063 1064" Lifelines (or Lex for C++!) 1065au BufNewFile,BufRead *.ll setf lifelines 1066 1067" Lilo: Linux loader 1068au BufNewFile,BufRead lilo.conf setf lilo 1069 1070" Lisp (*.el = ELisp, *.cl = Common Lisp, *.jl = librep Lisp) 1071if has("fname_case") 1072 au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,*.L,.emacs,.sawfishrc setf lisp 1073else 1074 au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,.emacs,.sawfishrc setf lisp 1075endif 1076 1077" SBCL implementation of Common Lisp 1078au BufNewFile,BufRead sbclrc,.sbclrc setf lisp 1079 1080" Liquid 1081au BufNewFile,BufRead *.liquid setf liquid 1082 1083" Lite 1084au BufNewFile,BufRead *.lite,*.lt setf lite 1085 1086" LiteStep RC files 1087au BufNewFile,BufRead */LiteStep/*/*.rc setf litestep 1088 1089" Login access 1090au BufNewFile,BufRead */etc/login.access setf loginaccess 1091 1092" Login defs 1093au BufNewFile,BufRead */etc/login.defs setf logindefs 1094 1095" Logtalk 1096au BufNewFile,BufRead *.lgt setf logtalk 1097 1098" LOTOS 1099au BufNewFile,BufRead *.lot,*.lotos setf lotos 1100 1101" Lout (also: *.lt) 1102au BufNewFile,BufRead *.lou,*.lout setf lout 1103 1104" Lua 1105au BufNewFile,BufRead *.lua setf lua 1106 1107" Luarocks 1108au BufNewFile,BufRead *.rockspec setf lua 1109 1110" Linden Scripting Language (Second Life) 1111au BufNewFile,BufRead *.lsl setf lsl 1112 1113" Lynx style file (or LotusScript!) 1114au BufNewFile,BufRead *.lss setf lss 1115 1116" M4 1117au BufNewFile,BufRead *.m4 1118 \ if expand("<afile>") !~? 'html.m4$\|fvwm2rc' | setf m4 | endif 1119 1120" MaGic Point 1121au BufNewFile,BufRead *.mgp setf mgp 1122 1123" Mail (for Elm, trn, mutt, muttng, rn, slrn) 1124au BufNewFile,BufRead snd.\d\+,.letter,.letter.\d\+,.followup,.article,.article.\d\+,pico.\d\+,mutt{ng,}-*-\w\+,mutt[[:alnum:]_-]\\\{6\},ae\d\+.txt,/tmp/SLRN[0-9A-Z.]\+,*.eml setf mail 1125 1126" Mail aliases 1127au BufNewFile,BufRead */etc/mail/aliases,*/etc/aliases setf mailaliases 1128 1129" Mailcap configuration file 1130au BufNewFile,BufRead .mailcap,mailcap setf mailcap 1131 1132" Makefile 1133au BufNewFile,BufRead *[mM]akefile,*.mk,*.mak,*.dsp setf make 1134 1135" MakeIndex 1136au BufNewFile,BufRead *.ist,*.mst setf ist 1137 1138" Mallard 1139au BufNewFile,BufRead *.page setf mallard 1140 1141" Manpage 1142au BufNewFile,BufRead *.man setf man 1143 1144" Man config 1145au BufNewFile,BufRead */etc/man.conf,man.config setf manconf 1146 1147" Maple V 1148au BufNewFile,BufRead *.mv,*.mpl,*.mws setf maple 1149 1150" Map (UMN mapserver config file) 1151au BufNewFile,BufRead *.map setf map 1152 1153" Markdown 1154au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md setf markdown 1155 1156" Mason 1157au BufNewFile,BufRead *.mason,*.mhtml,*.comp setf mason 1158 1159" Matlab or Objective C 1160au BufNewFile,BufRead *.m call s:FTm() 1161 1162func! s:FTm() 1163 let n = 1 1164 while n < 10 1165 let line = getline(n) 1166 if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\|//\)' 1167 setf objc 1168 return 1169 endif 1170 if line =~ '^\s*%' 1171 setf matlab 1172 return 1173 endif 1174 if line =~ '^\s*(\*' 1175 setf mma 1176 return 1177 endif 1178 let n = n + 1 1179 endwhile 1180 if exists("g:filetype_m") 1181 exe "setf " . g:filetype_m 1182 else 1183 setf matlab 1184 endif 1185endfunc 1186 1187" Mathematica notebook 1188au BufNewFile,BufRead *.nb setf mma 1189 1190" Maya Extension Language 1191au BufNewFile,BufRead *.mel setf mel 1192 1193" Mercurial (hg) commit file 1194au BufNewFile,BufRead hg-editor-*.txt setf hgcommit 1195 1196" Mercurial config (looks like generic config file) 1197au BufNewFile,BufRead *.hgrc,*hgrc setf cfg 1198 1199" Messages (logs mostly) 1200au BufNewFile,BufRead */log/{auth,cron,daemon,debug,kern,lpr,mail,messages,news/news,syslog,user}{,.log,.err,.info,.warn,.crit,.notice}{,.[0-9]*,-[0-9]*} setf messages 1201 1202" Metafont 1203au BufNewFile,BufRead *.mf setf mf 1204 1205" MetaPost 1206au BufNewFile,BufRead *.mp setf mp 1207 1208" MGL 1209au BufNewFile,BufRead *.mgl setf mgl 1210 1211" MIX - Knuth assembly 1212au BufNewFile,BufRead *.mix,*.mixal setf mix 1213 1214" MMIX or VMS makefile 1215au BufNewFile,BufRead *.mms call s:FTmms() 1216 1217" Symbian meta-makefile definition (MMP) 1218au BufNewFile,BufRead *.mmp setf mmp 1219 1220func! s:FTmms() 1221 let n = 1 1222 while n < 10 1223 let line = getline(n) 1224 if line =~ '^\s*\(%\|//\)' || line =~ '^\*' 1225 setf mmix 1226 return 1227 endif 1228 if line =~ '^\s*#' 1229 setf make 1230 return 1231 endif 1232 let n = n + 1 1233 endwhile 1234 setf mmix 1235endfunc 1236 1237 1238" Modsim III (or LambdaProlog) 1239au BufNewFile,BufRead *.mod 1240 \ if getline(1) =~ '\<module\>' | 1241 \ setf lprolog | 1242 \ else | 1243 \ setf modsim3 | 1244 \ endif 1245 1246" Modula 2 (.md removed in favor of Markdown) 1247au BufNewFile,BufRead *.m2,*.DEF,*.MOD,*.mi setf modula2 1248 1249" Modula 3 (.m3, .i3, .mg, .ig) 1250au BufNewFile,BufRead *.[mi][3g] setf modula3 1251 1252" Monk 1253au BufNewFile,BufRead *.isc,*.monk,*.ssc,*.tsc setf monk 1254 1255" MOO 1256au BufNewFile,BufRead *.moo setf moo 1257 1258" Modconf 1259au BufNewFile,BufRead */etc/modules.conf,*/etc/modules,*/etc/conf.modules setf modconf 1260 1261" Mplayer config 1262au BufNewFile,BufRead mplayer.conf,*/.mplayer/config setf mplayerconf 1263 1264" Moterola S record 1265au BufNewFile,BufRead *.s19,*.s28,*.s37 setf srec 1266 1267" Mrxvtrc 1268au BufNewFile,BufRead mrxvtrc,.mrxvtrc setf mrxvtrc 1269 1270" Msql 1271au BufNewFile,BufRead *.msql setf msql 1272 1273" Mysql 1274au BufNewFile,BufRead *.mysql setf mysql 1275 1276" Mutt setup files (must be before catch *.rc) 1277au BufNewFile,BufRead */etc/Muttrc.d/* call s:StarSetf('muttrc') 1278 1279" M$ Resource files 1280au BufNewFile,BufRead *.rc,*.rch setf rc 1281 1282" MuPAD source 1283au BufRead,BufNewFile *.mu setf mupad 1284 1285" Mush 1286au BufNewFile,BufRead *.mush setf mush 1287 1288" Mutt setup file (also for Muttng) 1289au BufNewFile,BufRead Mutt{ng,}rc setf muttrc 1290 1291" Nano 1292au BufNewFile,BufRead */etc/nanorc,.nanorc setf nanorc 1293 1294" Nastran input/DMAP 1295"au BufNewFile,BufRead *.dat setf nastran 1296 1297" Natural 1298au BufNewFile,BufRead *.NS[ACGLMNPS] setf natural 1299 1300" Netrc 1301au BufNewFile,BufRead .netrc setf netrc 1302 1303" Ninja file 1304au BufNewFile,BufRead *.ninja setf ninja 1305 1306" Novell netware batch files 1307au BufNewFile,BufRead *.ncf setf ncf 1308 1309" Nroff/Troff (*.ms and *.t are checked below) 1310au BufNewFile,BufRead *.me 1311 \ if expand("<afile>") != "read.me" && expand("<afile>") != "click.me" | 1312 \ setf nroff | 1313 \ endif 1314au BufNewFile,BufRead *.tr,*.nr,*.roff,*.tmac,*.mom setf nroff 1315au BufNewFile,BufRead *.[1-9] call s:FTnroff() 1316 1317" This function checks if one of the first five lines start with a dot. In 1318" that case it is probably an nroff file: 'filetype' is set and 1 is returned. 1319func! s:FTnroff() 1320 if getline(1)[0] . getline(2)[0] . getline(3)[0] . getline(4)[0] . getline(5)[0] =~ '\.' 1321 setf nroff 1322 return 1 1323 endif 1324 return 0 1325endfunc 1326 1327" Nroff or Objective C++ 1328au BufNewFile,BufRead *.mm call s:FTmm() 1329 1330func! s:FTmm() 1331 let n = 1 1332 while n < 10 1333 let line = getline(n) 1334 if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)' 1335 setf objcpp 1336 return 1337 endif 1338 let n = n + 1 1339 endwhile 1340 setf nroff 1341endfunc 1342 1343" Not Quite C 1344au BufNewFile,BufRead *.nqc setf nqc 1345 1346" NSIS 1347au BufNewFile,BufRead *.nsi,*.nsh setf nsis 1348 1349" OCAML 1350au BufNewFile,BufRead *.ml,*.mli,*.mll,*.mly,.ocamlinit setf ocaml 1351 1352" Occam 1353au BufNewFile,BufRead *.occ setf occam 1354 1355" Omnimark 1356au BufNewFile,BufRead *.xom,*.xin setf omnimark 1357 1358" OpenROAD 1359au BufNewFile,BufRead *.or setf openroad 1360 1361" OPL 1362au BufNewFile,BufRead *.[Oo][Pp][Ll] setf opl 1363 1364" Oracle config file 1365au BufNewFile,BufRead *.ora setf ora 1366 1367" Packet filter conf 1368au BufNewFile,BufRead pf.conf setf pf 1369 1370" Pam conf 1371au BufNewFile,BufRead */etc/pam.conf setf pamconf 1372 1373" PApp 1374au BufNewFile,BufRead *.papp,*.pxml,*.pxsl setf papp 1375 1376" Password file 1377au BufNewFile,BufRead */etc/passwd,*/etc/passwd-,*/etc/passwd.edit,*/etc/shadow,*/etc/shadow-,*/etc/shadow.edit,*/var/backups/passwd.bak,*/var/backups/shadow.bak setf passwd 1378 1379" Pascal (also *.p) 1380au BufNewFile,BufRead *.pas setf pascal 1381 1382" Delphi project file 1383au BufNewFile,BufRead *.dpr setf pascal 1384 1385" PDF 1386au BufNewFile,BufRead *.pdf setf pdf 1387 1388" Perl 1389if has("fname_case") 1390 au BufNewFile,BufRead *.pl,*.PL call s:FTpl() 1391else 1392 au BufNewFile,BufRead *.pl call s:FTpl() 1393endif 1394au BufNewFile,BufRead *.plx,*.al setf perl 1395au BufNewFile,BufRead *.p6,*.pm6 setf perl6 1396 1397func! s:FTpl() 1398 if exists("g:filetype_pl") 1399 exe "setf " . g:filetype_pl 1400 else 1401 " recognize Prolog by specific text in the first non-empty line 1402 " require a blank after the '%' because Perl uses "%list" and "%translate" 1403 let l = getline(nextnonblank(1)) 1404 if l =~ '\<prolog\>' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-' 1405 setf prolog 1406 else 1407 setf perl 1408 endif 1409 endif 1410endfunc 1411 1412" Perl, XPM or XPM2 1413au BufNewFile,BufRead *.pm 1414 \ if getline(1) =~ "XPM2" | 1415 \ setf xpm2 | 1416 \ elseif getline(1) =~ "XPM" | 1417 \ setf xpm | 1418 \ else | 1419 \ setf perl | 1420 \ endif 1421 1422" Perl POD 1423au BufNewFile,BufRead *.pod setf pod 1424 1425" Php, php3, php4, etc. 1426" Also Phtml (was used for PHP 2 in the past) 1427" Also .ctp for Cake template file 1428au BufNewFile,BufRead *.php,*.php\d,*.phtml,*.ctp setf php 1429 1430" Pike 1431au BufNewFile,BufRead *.pike,*.lpc,*.ulpc,*.pmod setf pike 1432 1433" Pinfo config 1434au BufNewFile,BufRead */etc/pinforc,*/.pinforc setf pinfo 1435 1436" Palm Resource compiler 1437au BufNewFile,BufRead *.rcp setf pilrc 1438 1439" Pine config 1440au BufNewFile,BufRead .pinerc,pinerc,.pinercex,pinercex setf pine 1441 1442" PL/1, PL/I 1443au BufNewFile,BufRead *.pli,*.pl1 setf pli 1444 1445" PL/M (also: *.inp) 1446au BufNewFile,BufRead *.plm,*.p36,*.pac setf plm 1447 1448" PL/SQL 1449au BufNewFile,BufRead *.pls,*.plsql setf plsql 1450 1451" PLP 1452au BufNewFile,BufRead *.plp setf plp 1453 1454" PO and PO template (GNU gettext) 1455au BufNewFile,BufRead *.po,*.pot setf po 1456 1457" Postfix main config 1458au BufNewFile,BufRead main.cf setf pfmain 1459 1460" PostScript (+ font files, encapsulated PostScript, Adobe Illustrator) 1461au BufNewFile,BufRead *.ps,*.pfa,*.afm,*.eps,*.epsf,*.epsi,*.ai setf postscr 1462 1463" PostScript Printer Description 1464au BufNewFile,BufRead *.ppd setf ppd 1465 1466" Povray 1467au BufNewFile,BufRead *.pov setf pov 1468 1469" Povray configuration 1470au BufNewFile,BufRead .povrayrc setf povini 1471 1472" Povray, PHP or assembly 1473au BufNewFile,BufRead *.inc call s:FTinc() 1474 1475func! s:FTinc() 1476 if exists("g:filetype_inc") 1477 exe "setf " . g:filetype_inc 1478 else 1479 let lines = getline(1).getline(2).getline(3) 1480 if lines =~? "perlscript" 1481 setf aspperl 1482 elseif lines =~ "<%" 1483 setf aspvbs 1484 elseif lines =~ "<?" 1485 setf php 1486 else 1487 call s:FTasmsyntax() 1488 if exists("b:asmsyntax") 1489 exe "setf " . fnameescape(b:asmsyntax) 1490 else 1491 setf pov 1492 endif 1493 endif 1494 endif 1495endfunc 1496 1497" Printcap and Termcap 1498au BufNewFile,BufRead *printcap 1499 \ let b:ptcap_type = "print" | setf ptcap 1500au BufNewFile,BufRead *termcap 1501 \ let b:ptcap_type = "term" | setf ptcap 1502 1503" PCCTS / ANTRL 1504"au BufNewFile,BufRead *.g setf antrl 1505au BufNewFile,BufRead *.g setf pccts 1506 1507" PPWizard 1508au BufNewFile,BufRead *.it,*.ih setf ppwiz 1509 1510" Obj 3D file format 1511" TODO: is there a way to avoid MS-Windows Object files? 1512au BufNewFile,BufRead *.obj setf obj 1513 1514" Oracle Pro*C/C++ 1515au BufNewFile,BufRead *.pc setf proc 1516 1517" Privoxy actions file 1518au BufNewFile,BufRead *.action setf privoxy 1519 1520" Procmail 1521au BufNewFile,BufRead .procmail,.procmailrc setf procmail 1522 1523" Progress or CWEB 1524au BufNewFile,BufRead *.w call s:FTprogress_cweb() 1525 1526func! s:FTprogress_cweb() 1527 if exists("g:filetype_w") 1528 exe "setf " . g:filetype_w 1529 return 1530 endif 1531 if getline(1) =~ '&ANALYZE' || getline(3) =~ '&GLOBAL-DEFINE' 1532 setf progress 1533 else 1534 setf cweb 1535 endif 1536endfunc 1537 1538" Progress or assembly 1539au BufNewFile,BufRead *.i call s:FTprogress_asm() 1540 1541func! s:FTprogress_asm() 1542 if exists("g:filetype_i") 1543 exe "setf " . g:filetype_i 1544 return 1545 endif 1546 " This function checks for an assembly comment the first ten lines. 1547 " If not found, assume Progress. 1548 let lnum = 1 1549 while lnum <= 10 && lnum < line('$') 1550 let line = getline(lnum) 1551 if line =~ '^\s*;' || line =~ '^\*' 1552 call s:FTasm() 1553 return 1554 elseif line !~ '^\s*$' || line =~ '^/\*' 1555 " Not an empty line: Doesn't look like valid assembly code. 1556 " Or it looks like a Progress /* comment 1557 break 1558 endif 1559 let lnum = lnum + 1 1560 endw 1561 setf progress 1562endfunc 1563 1564" Progress or Pascal 1565au BufNewFile,BufRead *.p call s:FTprogress_pascal() 1566 1567func! s:FTprogress_pascal() 1568 if exists("g:filetype_p") 1569 exe "setf " . g:filetype_p 1570 return 1571 endif 1572 " This function checks for valid Pascal syntax in the first ten lines. 1573 " Look for either an opening comment or a program start. 1574 " If not found, assume Progress. 1575 let lnum = 1 1576 while lnum <= 10 && lnum < line('$') 1577 let line = getline(lnum) 1578 if line =~ '^\s*\(program\|unit\|procedure\|function\|const\|type\|var\)\>' 1579 \ || line =~ '^\s*{' || line =~ '^\s*(\*' 1580 setf pascal 1581 return 1582 elseif line !~ '^\s*$' || line =~ '^/\*' 1583 " Not an empty line: Doesn't look like valid Pascal code. 1584 " Or it looks like a Progress /* comment 1585 break 1586 endif 1587 let lnum = lnum + 1 1588 endw 1589 setf progress 1590endfunc 1591 1592 1593" Software Distributor Product Specification File (POSIX 1387.2-1995) 1594au BufNewFile,BufRead *.psf setf psf 1595au BufNewFile,BufRead INDEX,INFO 1596 \ if getline(1) =~ '^\s*\(distribution\|installed_software\|root\|bundle\|product\)\s*$' | 1597 \ setf psf | 1598 \ endif 1599 1600" Prolog 1601au BufNewFile,BufRead *.pdb setf prolog 1602 1603" Promela 1604au BufNewFile,BufRead *.pml setf promela 1605 1606" Google protocol buffers 1607au BufNewFile,BufRead *.proto setf proto 1608 1609" Protocols 1610au BufNewFile,BufRead */etc/protocols setf protocols 1611 1612" Pyrex 1613au BufNewFile,BufRead *.pyx,*.pxd setf pyrex 1614 1615" Python 1616au BufNewFile,BufRead *.py,*.pyw setf python 1617 1618" Quixote (Python-based web framework) 1619au BufNewFile,BufRead *.ptl setf python 1620 1621" Radiance 1622au BufNewFile,BufRead *.rad,*.mat setf radiance 1623 1624" Ratpoison config/command files 1625au BufNewFile,BufRead .ratpoisonrc,ratpoisonrc setf ratpoison 1626 1627" RCS file 1628au BufNewFile,BufRead *\,v setf rcs 1629 1630" Readline 1631au BufNewFile,BufRead .inputrc,inputrc setf readline 1632 1633" Registry for MS-Windows 1634au BufNewFile,BufRead *.reg 1635 \ if getline(1) =~? '^REGEDIT[0-9]*\s*$\|^Windows Registry Editor Version \d*\.\d*\s*$' | setf registry | endif 1636 1637" Renderman Interface Bytestream 1638au BufNewFile,BufRead *.rib setf rib 1639 1640" Rexx 1641au BufNewFile,BufRead *.rex,*.orx,*.rxo,*.rxj,*.jrexx,*.rexxj,*.rexx,*.testGroup,*.testUnit setf rexx 1642 1643" R (Splus) 1644if has("fname_case") 1645 au BufNewFile,BufRead *.s,*.S setf r 1646else 1647 au BufNewFile,BufRead *.s setf r 1648endif 1649 1650" R Help file 1651if has("fname_case") 1652 au BufNewFile,BufRead *.rd,*.Rd setf rhelp 1653else 1654 au BufNewFile,BufRead *.rd setf rhelp 1655endif 1656 1657" R noweb file 1658if has("fname_case") 1659 au BufNewFile,BufRead *.Rnw,*.rnw,*.Snw,*.snw setf rnoweb 1660else 1661 au BufNewFile,BufRead *.rnw,*.snw setf rnoweb 1662endif 1663 1664" R Markdown file 1665if has("fname_case") 1666 au BufNewFile,BufRead *.Rmd,*.rmd,*.Smd,*.smd setf rmd 1667else 1668 au BufNewFile,BufRead *.rmd,*.smd setf rmd 1669endif 1670 1671" R reStructuredText file 1672if has("fname_case") 1673 au BufNewFile,BufRead *.Rrst,*.rrst,*.Srst,*.srst setf rrst 1674else 1675 au BufNewFile,BufRead *.rrst,*.srst setf rrst 1676endif 1677 1678" Rexx, Rebol or R 1679au BufNewFile,BufRead *.r,*.R call s:FTr() 1680 1681func! s:FTr() 1682 let max = line("$") > 50 ? 50 : line("$") 1683 1684 for n in range(1, max) 1685 " Rebol is easy to recognize, check for that first 1686 if getline(n) =~? '\<REBOL\>' 1687 setf rebol 1688 return 1689 endif 1690 endfor 1691 1692 for n in range(1, max) 1693 " R has # comments 1694 if getline(n) =~ '^\s*#' 1695 setf r 1696 return 1697 endif 1698 " Rexx has /* comments */ 1699 if getline(n) =~ '^\s*/\*' 1700 setf rexx 1701 return 1702 endif 1703 endfor 1704 1705 " Nothing recognized, use user default or assume Rexx 1706 if exists("g:filetype_r") 1707 exe "setf " . g:filetype_r 1708 else 1709 " Rexx used to be the default, but R appears to be much more popular. 1710 setf r 1711 endif 1712endfunc 1713 1714" Remind 1715au BufNewFile,BufRead .reminders,*.remind,*.rem setf remind 1716 1717" Resolv.conf 1718au BufNewFile,BufRead resolv.conf setf resolv 1719 1720" Relax NG Compact 1721au BufNewFile,BufRead *.rnc setf rnc 1722 1723" Relax NG XML 1724au BufNewFile,BufRead *.rng setf rng 1725 1726" RPL/2 1727au BufNewFile,BufRead *.rpl setf rpl 1728 1729" Robots.txt 1730au BufNewFile,BufRead robots.txt setf robots 1731 1732" Rpcgen 1733au BufNewFile,BufRead *.x setf rpcgen 1734 1735" reStructuredText Documentation Format 1736au BufNewFile,BufRead *.rst setf rst 1737 1738" RTF 1739au BufNewFile,BufRead *.rtf setf rtf 1740 1741" Interactive Ruby shell 1742au BufNewFile,BufRead .irbrc,irbrc setf ruby 1743 1744" Ruby 1745au BufNewFile,BufRead *.rb,*.rbw setf ruby 1746 1747" RubyGems 1748au BufNewFile,BufRead *.gemspec setf ruby 1749 1750" Rackup 1751au BufNewFile,BufRead *.ru setf ruby 1752 1753" Bundler 1754au BufNewFile,BufRead Gemfile setf ruby 1755 1756" Ruby on Rails 1757au BufNewFile,BufRead *.builder,*.rxml,*.rjs setf ruby 1758 1759" Rantfile and Rakefile is like Ruby 1760au BufNewFile,BufRead [rR]antfile,*.rant,[rR]akefile,*.rake setf ruby 1761 1762" S-lang (or shader language, or SmallLisp) 1763au BufNewFile,BufRead *.sl setf slang 1764 1765" Samba config 1766au BufNewFile,BufRead smb.conf setf samba 1767 1768" SAS script 1769au BufNewFile,BufRead *.sas setf sas 1770 1771" Sass 1772au BufNewFile,BufRead *.sass setf sass 1773 1774" Sather 1775au BufNewFile,BufRead *.sa setf sather 1776 1777" Scilab 1778au BufNewFile,BufRead *.sci,*.sce setf scilab 1779 1780" SCSS 1781au BufNewFile,BufRead *.scss setf scss 1782 1783" SD: Streaming Descriptors 1784au BufNewFile,BufRead *.sd setf sd 1785 1786" SDL 1787au BufNewFile,BufRead *.sdl,*.pr setf sdl 1788 1789" sed 1790au BufNewFile,BufRead *.sed setf sed 1791 1792" Sieve (RFC 3028) 1793au BufNewFile,BufRead *.siv setf sieve 1794 1795" Sendmail 1796au BufNewFile,BufRead sendmail.cf setf sm 1797 1798" Sendmail .mc files are actually m4. Could also be MS Message text file. 1799au BufNewFile,BufRead *.mc call s:McSetf() 1800 1801func! s:McSetf() 1802 " Rely on the file to start with a comment. 1803 " MS message text files use ';', Sendmail files use '#' or 'dnl' 1804 for lnum in range(1, min([line("$"), 20])) 1805 let line = getline(lnum) 1806 if line =~ '^\s*\(#\|dnl\)' 1807 setf m4 " Sendmail .mc file 1808 return 1809 elseif line =~ '^\s*;' 1810 setf msmessages " MS Message text file 1811 return 1812 endif 1813 endfor 1814 setf m4 " Default: Sendmail .mc file 1815endfunc 1816 1817" Services 1818au BufNewFile,BufRead */etc/services setf services 1819 1820" Service Location config 1821au BufNewFile,BufRead */etc/slp.conf setf slpconf 1822 1823" Service Location registration 1824au BufNewFile,BufRead */etc/slp.reg setf slpreg 1825 1826" Service Location SPI 1827au BufNewFile,BufRead */etc/slp.spi setf slpspi 1828 1829" Setserial config 1830au BufNewFile,BufRead */etc/serial.conf setf setserial 1831 1832" SGML 1833au BufNewFile,BufRead *.sgm,*.sgml 1834 \ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'linuxdoc' | 1835 \ setf sgmllnx | 1836 \ elseif getline(1) =~ '<!DOCTYPE.*DocBook' || getline(2) =~ '<!DOCTYPE.*DocBook' | 1837 \ let b:docbk_type = "sgml" | 1838 \ let b:docbk_ver = 4 | 1839 \ setf docbk | 1840 \ else | 1841 \ setf sgml | 1842 \ endif 1843 1844" SGMLDECL 1845au BufNewFile,BufRead *.decl,*.dcl,*.dec 1846 \ if getline(1).getline(2).getline(3) =~? '^<!SGML' | 1847 \ setf sgmldecl | 1848 \ endif 1849 1850" SGML catalog file 1851au BufNewFile,BufRead catalog setf catalog 1852au BufNewFile,BufRead sgml.catalog* call s:StarSetf('catalog') 1853 1854" Shell scripts (sh, ksh, bash, bash2, csh); Allow .profile_foo etc. 1855" Gentoo ebuilds are actually bash scripts 1856au BufNewFile,BufRead .bashrc*,bashrc,bash.bashrc,.bash_profile*,.bash_logout*,*.bash,*.ebuild call SetFileTypeSH("bash") 1857au BufNewFile,BufRead .kshrc*,*.ksh call SetFileTypeSH("ksh") 1858au BufNewFile,BufRead */etc/profile,.profile*,*.sh,*.env call SetFileTypeSH(getline(1)) 1859 1860" Also called from scripts.vim. 1861func! SetFileTypeSH(name) 1862 if expand("<amatch>") =~ g:ft_ignore_pat 1863 return 1864 endif 1865 if a:name =~ '\<csh\>' 1866 " Some .sh scripts contain #!/bin/csh. 1867 call SetFileTypeShell("csh") 1868 return 1869 elseif a:name =~ '\<tcsh\>' 1870 " Some .sh scripts contain #!/bin/tcsh. 1871 call SetFileTypeShell("tcsh") 1872 return 1873 elseif a:name =~ '\<zsh\>' 1874 " Some .sh scripts contain #!/bin/zsh. 1875 call SetFileTypeShell("zsh") 1876 return 1877 elseif a:name =~ '\<ksh\>' 1878 let b:is_kornshell = 1 1879 if exists("b:is_bash") 1880 unlet b:is_bash 1881 endif 1882 if exists("b:is_sh") 1883 unlet b:is_sh 1884 endif 1885 elseif exists("g:bash_is_sh") || a:name =~ '\<bash\>' || a:name =~ '\<bash2\>' 1886 let b:is_bash = 1 1887 if exists("b:is_kornshell") 1888 unlet b:is_kornshell 1889 endif 1890 if exists("b:is_sh") 1891 unlet b:is_sh 1892 endif 1893 elseif a:name =~ '\<sh\>' 1894 let b:is_sh = 1 1895 if exists("b:is_kornshell") 1896 unlet b:is_kornshell 1897 endif 1898 if exists("b:is_bash") 1899 unlet b:is_bash 1900 endif 1901 endif 1902 call SetFileTypeShell("sh") 1903endfunc 1904 1905" For shell-like file types, check for an "exec" command hidden in a comment, 1906" as used for Tcl. 1907" Also called from scripts.vim, thus can't be local to this script. 1908func! SetFileTypeShell(name) 1909 if expand("<amatch>") =~ g:ft_ignore_pat 1910 return 1911 endif 1912 let l = 2 1913 while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)' 1914 " Skip empty and comment lines. 1915 let l = l + 1 1916 endwhile 1917 if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$' 1918 " Found an "exec" line after a comment with continuation 1919 let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '') 1920 if n =~ '\<tclsh\|\<wish' 1921 setf tcl 1922 return 1923 endif 1924 endif 1925 exe "setf " . a:name 1926endfunc 1927 1928" tcsh scripts 1929au BufNewFile,BufRead .tcshrc*,*.tcsh,tcsh.tcshrc,tcsh.login call SetFileTypeShell("tcsh") 1930 1931" csh scripts, but might also be tcsh scripts (on some systems csh is tcsh) 1932au BufNewFile,BufRead .login*,.cshrc*,csh.cshrc,csh.login,csh.logout,*.csh,.alias call s:CSH() 1933 1934func! s:CSH() 1935 if exists("g:filetype_csh") 1936 call SetFileTypeShell(g:filetype_csh) 1937 elseif &shell =~ "tcsh" 1938 call SetFileTypeShell("tcsh") 1939 else 1940 call SetFileTypeShell("csh") 1941 endif 1942endfunc 1943 1944" Z-Shell script 1945au BufNewFile,BufRead .zprofile,*/etc/zprofile,.zfbfmarks setf zsh 1946au BufNewFile,BufRead .zsh*,.zlog*,.zcompdump* call s:StarSetf('zsh') 1947au BufNewFile,BufRead *.zsh setf zsh 1948 1949" Scheme 1950au BufNewFile,BufRead *.scm,*.ss,*.rkt setf scheme 1951 1952" Screen RC 1953au BufNewFile,BufRead .screenrc,screenrc setf screen 1954 1955" Simula 1956au BufNewFile,BufRead *.sim setf simula 1957 1958" SINDA 1959au BufNewFile,BufRead *.sin,*.s85 setf sinda 1960 1961" SiSU 1962au BufNewFile,BufRead *.sst,*.ssm,*.ssi,*.-sst,*._sst setf sisu 1963au BufNewFile,BufRead *.sst.meta,*.-sst.meta,*._sst.meta setf sisu 1964 1965" SKILL 1966au BufNewFile,BufRead *.il,*.ils,*.cdf setf skill 1967 1968" SLRN 1969au BufNewFile,BufRead .slrnrc setf slrnrc 1970au BufNewFile,BufRead *.score setf slrnsc 1971 1972" Smalltalk (and TeX) 1973au BufNewFile,BufRead *.st setf st 1974au BufNewFile,BufRead *.cls 1975 \ if getline(1) =~ '^%' | 1976 \ setf tex | 1977 \ elseif getline(1)[0] == '#' && getline(1) =~ 'rexx' | 1978 \ setf rexx | 1979 \ else | 1980 \ setf st | 1981 \ endif 1982 1983" Smarty templates 1984au BufNewFile,BufRead *.tpl setf smarty 1985 1986" SMIL or XML 1987au BufNewFile,BufRead *.smil 1988 \ if getline(1) =~ '<?\s*xml.*?>' | 1989 \ setf xml | 1990 \ else | 1991 \ setf smil | 1992 \ endif 1993 1994" SMIL or SNMP MIB file 1995au BufNewFile,BufRead *.smi 1996 \ if getline(1) =~ '\<smil\>' | 1997 \ setf smil | 1998 \ else | 1999 \ setf mib | 2000 \ endif 2001 2002" SMITH 2003au BufNewFile,BufRead *.smt,*.smith setf smith 2004 2005" Snobol4 and spitbol 2006au BufNewFile,BufRead *.sno,*.spt setf snobol4 2007 2008" SNMP MIB files 2009au BufNewFile,BufRead *.mib,*.my setf mib 2010 2011" Snort Configuration 2012au BufNewFile,BufRead *.hog,snort.conf,vision.conf setf hog 2013au BufNewFile,BufRead *.rules call s:FTRules() 2014 2015let s:ft_rules_udev_rules_pattern = '^\s*\cudev_rules\s*=\s*"\([^"]\{-1,}\)/*".*' 2016func! s:FTRules() 2017 let path = expand('<amatch>:p') 2018 if path =~ '^/\(etc/udev/\%(rules\.d/\)\=.*\.rules\|lib/udev/\%(rules\.d/\)\=.*\.rules\)$' 2019 setf udevrules 2020 return 2021 endif 2022 if path =~ '^/etc/ufw/' 2023 setf conf " Better than hog 2024 return 2025 endif 2026 try 2027 let config_lines = readfile('/etc/udev/udev.conf') 2028 catch /^Vim\%((\a\+)\)\=:E484/ 2029 setf hog 2030 return 2031 endtry 2032 let dir = expand('<amatch>:p:h') 2033 for line in config_lines 2034 if line =~ s:ft_rules_udev_rules_pattern 2035 let udev_rules = substitute(line, s:ft_rules_udev_rules_pattern, '\1', "") 2036 if dir == udev_rules 2037 setf udevrules 2038 endif 2039 break 2040 endif 2041 endfor 2042 setf hog 2043endfunc 2044 2045 2046" Spec (Linux RPM) 2047au BufNewFile,BufRead *.spec setf spec 2048 2049" Speedup (AspenTech plant simulator) 2050au BufNewFile,BufRead *.speedup,*.spdata,*.spd setf spup 2051 2052" Slice 2053au BufNewFile,BufRead *.ice setf slice 2054 2055" Spice 2056au BufNewFile,BufRead *.sp,*.spice setf spice 2057 2058" Spyce 2059au BufNewFile,BufRead *.spy,*.spi setf spyce 2060 2061" Squid 2062au BufNewFile,BufRead squid.conf setf squid 2063 2064" SQL for Oracle Designer 2065au BufNewFile,BufRead *.tyb,*.typ,*.tyc,*.pkb,*.pks setf sql 2066 2067" SQL 2068au BufNewFile,BufRead *.sql call s:SQL() 2069 2070func! s:SQL() 2071 if exists("g:filetype_sql") 2072 exe "setf " . g:filetype_sql 2073 else 2074 setf sql 2075 endif 2076endfunc 2077 2078" SQLJ 2079au BufNewFile,BufRead *.sqlj setf sqlj 2080 2081" SQR 2082au BufNewFile,BufRead *.sqr,*.sqi setf sqr 2083 2084" OpenSSH configuration 2085au BufNewFile,BufRead ssh_config,*/.ssh/config setf sshconfig 2086 2087" OpenSSH server configuration 2088au BufNewFile,BufRead sshd_config setf sshdconfig 2089 2090" Stata 2091au BufNewFile,BufRead *.ado,*.class,*.do,*.imata,*.mata setf stata 2092 2093" SMCL 2094au BufNewFile,BufRead *.hlp,*.ihlp,*.smcl setf smcl 2095 2096" Stored Procedures 2097au BufNewFile,BufRead *.stp setf stp 2098 2099" Standard ML 2100au BufNewFile,BufRead *.sml setf sml 2101 2102" Sratus VOS command macro 2103au BufNewFile,BufRead *.cm setf voscm 2104 2105" Sysctl 2106au BufNewFile,BufRead */etc/sysctl.conf,*/etc/sysctl.d/*.conf setf sysctl 2107 2108" Synopsys Design Constraints 2109au BufNewFile,BufRead *.sdc setf sdc 2110 2111" Sudoers 2112au BufNewFile,BufRead */etc/sudoers,sudoers.tmp setf sudoers 2113 2114" SVG (Scalable Vector Graphics) 2115au BufNewFile,BufRead *.svg setf svg 2116 2117" If the file has an extension of 't' and is in a directory 't' or 'xt' then 2118" it is almost certainly a Perl test file. 2119" If the first line starts with '#' and contains 'perl' it's probably a Perl 2120" file. 2121" (Slow test) If a file contains a 'use' statement then it is almost certainly 2122" a Perl file. 2123func! s:FTperl() 2124 let dirname = expand("%:p:h:t") 2125 if expand("%:e") == 't' && (dirname == 't' || dirname == 'xt') 2126 setf perl 2127 return 1 2128 endif 2129 if getline(1)[0] == '#' && getline(1) =~ 'perl' 2130 setf perl 2131 return 1 2132 endif 2133 if search('^use\s\s*\k', 'nc', 30) 2134 setf perl 2135 return 1 2136 endif 2137 return 0 2138endfunc 2139 2140" Tads (or Nroff or Perl test file) 2141au BufNewFile,BufRead *.t 2142 \ if !s:FTnroff() && !s:FTperl() | setf tads | endif 2143 2144" Tags 2145au BufNewFile,BufRead tags setf tags 2146 2147" TAK 2148au BufNewFile,BufRead *.tak setf tak 2149 2150" Task 2151au BufRead,BufNewFile {pending,completed,undo}.data setf taskdata 2152au BufRead,BufNewFile *.task setf taskedit 2153 2154" Tcl (JACL too) 2155au BufNewFile,BufRead *.tcl,*.tk,*.itcl,*.itk,*.jacl setf tcl 2156 2157" TealInfo 2158au BufNewFile,BufRead *.tli setf tli 2159 2160" Telix Salt 2161au BufNewFile,BufRead *.slt setf tsalt 2162 2163" Terminfo 2164au BufNewFile,BufRead *.ti setf terminfo 2165 2166" TeX 2167au BufNewFile,BufRead *.latex,*.sty,*.dtx,*.ltx,*.bbl setf tex 2168au BufNewFile,BufRead *.tex call s:FTtex() 2169 2170" Choose context, plaintex, or tex (LaTeX) based on these rules: 2171" 1. Check the first line of the file for "%&<format>". 2172" 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords. 2173" 3. Default to "latex" or to g:tex_flavor, can be set in user's vimrc. 2174func! s:FTtex() 2175 let firstline = getline(1) 2176 if firstline =~ '^%&\s*\a\+' 2177 let format = tolower(matchstr(firstline, '\a\+')) 2178 let format = substitute(format, 'pdf', '', '') 2179 if format == 'tex' 2180 let format = 'plain' 2181 endif 2182 else 2183 " Default value, may be changed later: 2184 let format = exists("g:tex_flavor") ? g:tex_flavor : 'plain' 2185 " Save position, go to the top of the file, find first non-comment line. 2186 let save_cursor = getpos('.') 2187 call cursor(1,1) 2188 let firstNC = search('^\s*[^[:space:]%]', 'c', 1000) 2189 if firstNC " Check the next thousand lines for a LaTeX or ConTeXt keyword. 2190 let lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>' 2191 let cpat = 'start\a\+\|setup\a\+\|usemodule\|enablemode\|enableregime\|setvariables\|useencoding\|usesymbols\|stelle\a\+\|verwende\a\+\|stel\a\+\|gebruik\a\+\|usa\a\+\|imposta\a\+\|regle\a\+\|utilisemodule\>' 2192 let kwline = search('^\s*\\\%(' . lpat . '\)\|^\s*\\\(' . cpat . '\)', 2193 \ 'cnp', firstNC + 1000) 2194 if kwline == 1 " lpat matched 2195 let format = 'latex' 2196 elseif kwline == 2 " cpat matched 2197 let format = 'context' 2198 endif " If neither matched, keep default set above. 2199 " let lline = search('^\s*\\\%(' . lpat . '\)', 'cn', firstNC + 1000) 2200 " let cline = search('^\s*\\\%(' . cpat . '\)', 'cn', firstNC + 1000) 2201 " if cline > 0 2202 " let format = 'context' 2203 " endif 2204 " if lline > 0 && (cline == 0 || cline > lline) 2205 " let format = 'tex' 2206 " endif 2207 endif " firstNC 2208 call setpos('.', save_cursor) 2209 endif " firstline =~ '^%&\s*\a\+' 2210 2211 " Translation from formats to file types. TODO: add AMSTeX, RevTex, others? 2212 if format == 'plain' 2213 setf plaintex 2214 elseif format == 'context' 2215 setf context 2216 else " probably LaTeX 2217 setf tex 2218 endif 2219 return 2220endfunc 2221 2222" ConTeXt 2223au BufNewFile,BufRead tex/context/*/*.tex,*.mkii,*.mkiv setf context 2224 2225" Texinfo 2226au BufNewFile,BufRead *.texinfo,*.texi,*.txi setf texinfo 2227 2228" TeX configuration 2229au BufNewFile,BufRead texmf.cnf setf texmf 2230 2231" Tidy config 2232au BufNewFile,BufRead .tidyrc,tidyrc setf tidy 2233 2234" TF mud client 2235au BufNewFile,BufRead *.tf,.tfrc,tfrc setf tf 2236 2237" TPP - Text Presentation Program 2238au BufNewFile,BufReadPost *.tpp setf tpp 2239 2240" Treetop 2241au BufRead,BufNewFile *.treetop setf treetop 2242 2243" Trustees 2244au BufNewFile,BufRead trustees.conf setf trustees 2245 2246" TSS - Geometry 2247au BufNewFile,BufReadPost *.tssgm setf tssgm 2248 2249" TSS - Optics 2250au BufNewFile,BufReadPost *.tssop setf tssop 2251 2252" TSS - Command Line (temporary) 2253au BufNewFile,BufReadPost *.tsscl setf tsscl 2254 2255" TWIG files 2256au BufNewFile,BufReadPost *.twig setf twig 2257 2258" Motif UIT/UIL files 2259au BufNewFile,BufRead *.uit,*.uil setf uil 2260 2261" Udev conf 2262au BufNewFile,BufRead */etc/udev/udev.conf setf udevconf 2263 2264" Udev permissions 2265au BufNewFile,BufRead */etc/udev/permissions.d/*.permissions setf udevperm 2266" 2267" Udev symlinks config 2268au BufNewFile,BufRead */etc/udev/cdsymlinks.conf setf sh 2269 2270" UnrealScript 2271au BufNewFile,BufRead *.uc setf uc 2272 2273" Updatedb 2274au BufNewFile,BufRead */etc/updatedb.conf setf updatedb 2275 2276" Upstart (init(8)) config files 2277au BufNewFile,BufRead */usr/share/upstart/*.conf setf upstart 2278au BufNewFile,BufRead */usr/share/upstart/*.override setf upstart 2279au BufNewFile,BufRead */etc/init/*.conf,*/etc/init/*.override setf upstart 2280au BufNewFile,BufRead */.init/*.conf,*/.init/*.override setf upstart 2281au BufNewFile,BufRead */.config/upstart/*.conf setf upstart 2282au BufNewFile,BufRead */.config/upstart/*.override setf upstart 2283 2284" Vera 2285au BufNewFile,BufRead *.vr,*.vri,*.vrh setf vera 2286 2287" Verilog HDL 2288au BufNewFile,BufRead *.v setf verilog 2289 2290" Verilog-AMS HDL 2291au BufNewFile,BufRead *.va,*.vams setf verilogams 2292 2293" SystemVerilog 2294au BufNewFile,BufRead *.sv,*.svh setf systemverilog 2295 2296" VHDL 2297au BufNewFile,BufRead *.hdl,*.vhd,*.vhdl,*.vbe,*.vst setf vhdl 2298au BufNewFile,BufRead *.vhdl_[0-9]* call s:StarSetf('vhdl') 2299 2300" Vim script 2301au BufNewFile,BufRead *.vim,*.vba,.exrc,_exrc setf vim 2302 2303" Viminfo file 2304au BufNewFile,BufRead .viminfo,_viminfo setf viminfo 2305 2306" Virata Config Script File or Drupal module 2307au BufRead,BufNewFile *.hw,*.module,*.pkg 2308 \ if getline(1) =~ '<?php' | 2309 \ setf php | 2310 \ else | 2311 \ setf virata | 2312 \ endif 2313 2314" Visual Basic (also uses *.bas) or FORM 2315au BufNewFile,BufRead *.frm call s:FTVB("form") 2316 2317" SaxBasic is close to Visual Basic 2318au BufNewFile,BufRead *.sba setf vb 2319 2320" Vgrindefs file 2321au BufNewFile,BufRead vgrindefs setf vgrindefs 2322 2323" VRML V1.0c 2324au BufNewFile,BufRead *.wrl setf vrml 2325 2326" Vroom (vim testing and executable documentation) 2327au BufNewFile,BufRead *.vroom setf vroom 2328 2329" Webmacro 2330au BufNewFile,BufRead *.wm setf webmacro 2331 2332" Wget config 2333au BufNewFile,BufRead .wgetrc,wgetrc setf wget 2334 2335" Website MetaLanguage 2336au BufNewFile,BufRead *.wml setf wml 2337 2338" Winbatch 2339au BufNewFile,BufRead *.wbt setf winbatch 2340 2341" WSML 2342au BufNewFile,BufRead *.wsml setf wsml 2343 2344" WvDial 2345au BufNewFile,BufRead wvdial.conf,.wvdialrc setf wvdial 2346 2347" CVS RC file 2348au BufNewFile,BufRead .cvsrc setf cvsrc 2349 2350" CVS commit file 2351au BufNewFile,BufRead cvs\d\+ setf cvs 2352 2353" WEB (*.web is also used for Winbatch: Guess, based on expecting "%" comment 2354" lines in a WEB file). 2355au BufNewFile,BufRead *.web 2356 \ if getline(1)[0].getline(2)[0].getline(3)[0].getline(4)[0].getline(5)[0] =~ "%" | 2357 \ setf web | 2358 \ else | 2359 \ setf winbatch | 2360 \ endif 2361 2362" Windows Scripting Host and Windows Script Component 2363au BufNewFile,BufRead *.ws[fc] setf wsh 2364 2365" XHTML 2366au BufNewFile,BufRead *.xhtml,*.xht setf xhtml 2367 2368" X Pixmap (dynamically sets colors, use BufEnter to make it work better) 2369au BufEnter *.xpm 2370 \ if getline(1) =~ "XPM2" | 2371 \ setf xpm2 | 2372 \ else | 2373 \ setf xpm | 2374 \ endif 2375au BufEnter *.xpm2 setf xpm2 2376 2377" XFree86 config 2378au BufNewFile,BufRead XF86Config 2379 \ if getline(1) =~ '\<XConfigurator\>' | 2380 \ let b:xf86conf_xfree86_version = 3 | 2381 \ endif | 2382 \ setf xf86conf 2383au BufNewFile,BufRead */xorg.conf.d/*.conf 2384 \ let b:xf86conf_xfree86_version = 4 | 2385 \ setf xf86conf 2386 2387" Xorg config 2388au BufNewFile,BufRead xorg.conf,xorg.conf-4 let b:xf86conf_xfree86_version = 4 | setf xf86conf 2389 2390" Xinetd conf 2391au BufNewFile,BufRead */etc/xinetd.conf setf xinetd 2392 2393" XS Perl extension interface language 2394au BufNewFile,BufRead *.xs setf xs 2395 2396" X resources file 2397au BufNewFile,BufRead .Xdefaults,.Xpdefaults,.Xresources,xdm-config,*.ad setf xdefaults 2398 2399" Xmath 2400au BufNewFile,BufRead *.msc,*.msf setf xmath 2401au BufNewFile,BufRead *.ms 2402 \ if !s:FTnroff() | setf xmath | endif 2403 2404" XML specific variants: docbk and xbl 2405au BufNewFile,BufRead *.xml call s:FTxml() 2406 2407func! s:FTxml() 2408 let n = 1 2409 while n < 100 && n < line("$") 2410 let line = getline(n) 2411 " DocBook 4 or DocBook 5. 2412 let is_docbook4 = line =~ '<!DOCTYPE.*DocBook' 2413 let is_docbook5 = line =~ ' xmlns="http://docbook.org/ns/docbook"' 2414 if is_docbook4 || is_docbook5 2415 let b:docbk_type = "xml" 2416 if is_docbook5 2417 let b:docbk_ver = 5 2418 else 2419 let b:docbk_ver = 4 2420 endif 2421 setf docbk 2422 return 2423 endif 2424 if line =~ 'xmlns:xbl="http://www.mozilla.org/xbl"' 2425 setf xbl 2426 return 2427 endif 2428 let n += 1 2429 endwhile 2430 setf xml 2431endfunc 2432 2433" XMI (holding UML models) is also XML 2434au BufNewFile,BufRead *.xmi setf xml 2435 2436" CSPROJ files are Visual Studio.NET's XML-based project config files 2437au BufNewFile,BufRead *.csproj,*.csproj.user setf xml 2438 2439" Qt Linguist translation source and Qt User Interface Files are XML 2440au BufNewFile,BufRead *.ts,*.ui setf xml 2441 2442" TPM's are RDF-based descriptions of TeX packages (Nikolai Weibull) 2443au BufNewFile,BufRead *.tpm setf xml 2444 2445" Xdg menus 2446au BufNewFile,BufRead */etc/xdg/menus/*.menu setf xml 2447 2448" ATI graphics driver configuration 2449au BufNewFile,BufRead fglrxrc setf xml 2450 2451" XLIFF (XML Localisation Interchange File Format) is also XML 2452au BufNewFile,BufRead *.xlf setf xml 2453au BufNewFile,BufRead *.xliff setf xml 2454 2455" XML User Interface Language 2456au BufNewFile,BufRead *.xul setf xml 2457 2458" X11 xmodmap (also see below) 2459au BufNewFile,BufRead *Xmodmap setf xmodmap 2460 2461" Xquery 2462au BufNewFile,BufRead *.xq,*.xql,*.xqm,*.xquery,*.xqy setf xquery 2463 2464" XSD 2465au BufNewFile,BufRead *.xsd setf xsd 2466 2467" Xslt 2468au BufNewFile,BufRead *.xsl,*.xslt setf xslt 2469 2470" Yacc 2471au BufNewFile,BufRead *.yy,*.yxx,*.y++ setf yacc 2472 2473" Yacc or racc 2474au BufNewFile,BufRead *.y call s:FTy() 2475 2476func! s:FTy() 2477 let n = 1 2478 while n < 100 && n < line("$") 2479 let line = getline(n) 2480 if line =~ '^\s*%' 2481 setf yacc 2482 return 2483 endif 2484 if getline(n) =~ '^\s*\(#\|class\>\)' && getline(n) !~ '^\s*#\s*include' 2485 setf racc 2486 return 2487 endif 2488 let n = n + 1 2489 endwhile 2490 setf yacc 2491endfunc 2492 2493 2494" Yaml 2495au BufNewFile,BufRead *.yaml,*.yml setf yaml 2496 2497" yum conf (close enough to dosini) 2498au BufNewFile,BufRead */etc/yum.conf setf dosini 2499 2500" Zimbu 2501au BufNewFile,BufRead *.zu setf zimbu 2502 2503" Zope 2504" dtml (zope dynamic template markup language), pt (zope page template), 2505" cpt (zope form controller page template) 2506au BufNewFile,BufRead *.dtml,*.pt,*.cpt call s:FThtml() 2507" zsql (zope sql method) 2508au BufNewFile,BufRead *.zsql call s:SQL() 2509 2510" Z80 assembler asz80 2511au BufNewFile,BufRead *.z8a setf z8a 2512 2513augroup END 2514 2515 2516" Source the user-specified filetype file, for backwards compatibility with 2517" Vim 5.x. 2518if exists("myfiletypefile") && filereadable(expand(myfiletypefile)) 2519 execute "source " . myfiletypefile 2520endif 2521 2522 2523" Check for "*" after loading myfiletypefile, so that scripts.vim is only used 2524" when there are no matching file name extensions. 2525" Don't do this for compressed files. 2526augroup filetypedetect 2527au BufNewFile,BufRead * 2528 \ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat 2529 \ | runtime! scripts.vim | endif 2530au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif 2531 2532 2533" Extra checks for when no filetype has been detected now. Mostly used for 2534" patterns that end in "*". E.g., "zsh*" matches "zsh.vim", but that's a Vim 2535" script file. 2536" Most of these should call s:StarSetf() to avoid names ending in .gz and the 2537" like are used. 2538 2539" More Apache config files 2540au BufNewFile,BufRead access.conf*,apache.conf*,apache2.conf*,httpd.conf*,srm.conf* call s:StarSetf('apache') 2541au BufNewFile,BufRead */etc/apache2/*.conf*,*/etc/apache2/conf.*/*,*/etc/apache2/mods-*/*,*/etc/apache2/sites-*/*,*/etc/httpd/conf.d/*.conf* call s:StarSetf('apache') 2542 2543" Asterisk config file 2544au BufNewFile,BufRead *asterisk/*.conf* call s:StarSetf('asterisk') 2545au BufNewFile,BufRead *asterisk*/*voicemail.conf* call s:StarSetf('asteriskvm') 2546 2547" Bazaar version control 2548au BufNewFile,BufRead bzr_log.* setf bzr 2549 2550" BIND zone 2551au BufNewFile,BufRead */named/db.*,*/bind/db.* call s:StarSetf('bindzone') 2552 2553" Calendar 2554au BufNewFile,BufRead */.calendar/*, 2555 \*/share/calendar/*/calendar.*,*/share/calendar/calendar.* 2556 \ call s:StarSetf('calendar') 2557 2558" Changelog 2559au BufNewFile,BufRead [cC]hange[lL]og* 2560 \ if getline(1) =~ '; urgency=' 2561 \| call s:StarSetf('debchangelog') 2562 \|else 2563 \| call s:StarSetf('changelog') 2564 \|endif 2565 2566" Crontab 2567au BufNewFile,BufRead crontab,crontab.*,*/etc/cron.d/* call s:StarSetf('crontab') 2568 2569" dnsmasq(8) configuration 2570au BufNewFile,BufRead */etc/dnsmasq.d/* call s:StarSetf('dnsmasq') 2571 2572" Dracula 2573au BufNewFile,BufRead drac.* call s:StarSetf('dracula') 2574 2575" Fvwm 2576au BufNewFile,BufRead */.fvwm/* call s:StarSetf('fvwm') 2577au BufNewFile,BufRead *fvwmrc*,*fvwm95*.hook 2578 \ let b:fvwm_version = 1 | call s:StarSetf('fvwm') 2579au BufNewFile,BufRead *fvwm2rc* 2580 \ if expand("<afile>:e") == "m4" 2581 \| call s:StarSetf('fvwm2m4') 2582 \|else 2583 \| let b:fvwm_version = 2 | call s:StarSetf('fvwm') 2584 \|endif 2585 2586" Gedcom 2587au BufNewFile,BufRead */tmp/lltmp* call s:StarSetf('gedcom') 2588 2589" GTK RC 2590au BufNewFile,BufRead .gtkrc*,gtkrc* call s:StarSetf('gtkrc') 2591 2592" Jam 2593au BufNewFile,BufRead Prl*.*,JAM*.* call s:StarSetf('jam') 2594 2595" Jargon 2596au! BufNewFile,BufRead *jarg* 2597 \ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'THIS IS THE JARGON FILE' 2598 \| call s:StarSetf('jargon') 2599 \|endif 2600 2601" Kconfig 2602au BufNewFile,BufRead Kconfig.* call s:StarSetf('kconfig') 2603 2604" Lilo: Linux loader 2605au BufNewFile,BufRead lilo.conf* call s:StarSetf('lilo') 2606 2607" Logcheck 2608au BufNewFile,BufRead */etc/logcheck/*.d*/* call s:StarSetf('logcheck') 2609 2610" Makefile 2611au BufNewFile,BufRead [mM]akefile* call s:StarSetf('make') 2612 2613" Ruby Makefile 2614au BufNewFile,BufRead [rR]akefile* call s:StarSetf('ruby') 2615 2616" Mail (also matches muttrc.vim, so this is below the other checks) 2617au BufNewFile,BufRead mutt[[:alnum:]._-]\\\{6\} setf mail 2618 2619" Modconf 2620au BufNewFile,BufRead */etc/modutils/* 2621 \ if executable(expand("<afile>")) != 1 2622 \| call s:StarSetf('modconf') 2623 \|endif 2624au BufNewFile,BufRead */etc/modprobe.* call s:StarSetf('modconf') 2625 2626" Mutt setup file 2627au BufNewFile,BufRead .mutt{ng,}rc*,*/.mutt{ng,}/mutt{ng,}rc* call s:StarSetf('muttrc') 2628au BufNewFile,BufRead mutt{ng,}rc*,Mutt{ng,}rc* call s:StarSetf('muttrc') 2629 2630" Nroff macros 2631au BufNewFile,BufRead tmac.* call s:StarSetf('nroff') 2632 2633" Pam conf 2634au BufNewFile,BufRead */etc/pam.d/* call s:StarSetf('pamconf') 2635 2636" Printcap and Termcap 2637au BufNewFile,BufRead *printcap* 2638 \ if !did_filetype() 2639 \| let b:ptcap_type = "print" | call s:StarSetf('ptcap') 2640 \|endif 2641au BufNewFile,BufRead *termcap* 2642 \ if !did_filetype() 2643 \| let b:ptcap_type = "term" | call s:StarSetf('ptcap') 2644 \|endif 2645 2646" ReDIF 2647" Only used when the .rdf file was not detected to be XML. 2648au BufRead,BufNewFile *.rdf call s:Redif() 2649func! s:Redif() 2650 let lnum = 1 2651 while lnum <= 5 && lnum < line('$') 2652 if getline(lnum) =~ "^\ctemplate-type:" 2653 setf redif 2654 return 2655 endif 2656 let lnum = lnum + 1 2657 endwhile 2658endfunc 2659 2660" Remind 2661au BufNewFile,BufRead .reminders* call s:StarSetf('remind') 2662 2663" Vim script 2664au BufNewFile,BufRead *vimrc* call s:StarSetf('vim') 2665 2666" Subversion commit file 2667au BufNewFile,BufRead svn-commit*.tmp setf svn 2668 2669" X resources file 2670au BufNewFile,BufRead Xresources*,*/app-defaults/*,*/Xresources/* call s:StarSetf('xdefaults') 2671 2672" XFree86 config 2673au BufNewFile,BufRead XF86Config-4* 2674 \ let b:xf86conf_xfree86_version = 4 | call s:StarSetf('xf86conf') 2675au BufNewFile,BufRead XF86Config* 2676 \ if getline(1) =~ '\<XConfigurator\>' 2677 \| let b:xf86conf_xfree86_version = 3 2678 \|endif 2679 \|call s:StarSetf('xf86conf') 2680 2681" X11 xmodmap 2682au BufNewFile,BufRead *xmodmap* call s:StarSetf('xmodmap') 2683 2684" Xinetd conf 2685au BufNewFile,BufRead */etc/xinetd.d/* call s:StarSetf('xinetd') 2686 2687" yum conf (close enough to dosini) 2688au BufNewFile,BufRead */etc/yum.repos.d/* call s:StarSetf('dosini') 2689 2690" Z-Shell script 2691au BufNewFile,BufRead zsh*,zlog* call s:StarSetf('zsh') 2692 2693 2694" Plain text files, needs to be far down to not override others. This avoids 2695" the "conf" type being used if there is a line starting with '#'. 2696au BufNewFile,BufRead *.txt,*.text,README setf text 2697 2698 2699" Use the filetype detect plugins. They may overrule any of the previously 2700" detected filetypes. 2701runtime! ftdetect/*.vim 2702 2703" NOTE: The above command could have ended the filetypedetect autocmd group 2704" and started another one. Let's make sure it has ended to get to a consistent 2705" state. 2706augroup END 2707 2708" Generic configuration file (check this last, it's just guessing!) 2709au filetypedetect BufNewFile,BufRead,StdinReadPost * 2710 \ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat 2711 \ && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#' 2712 \ || getline(4) =~ '^#' || getline(5) =~ '^#') | 2713 \ setf conf | 2714 \ endif 2715 2716 2717" If the GUI is already running, may still need to install the Syntax menu. 2718" Don't do it when the 'M' flag is included in 'guioptions'. 2719if has("menu") && has("gui_running") 2720 \ && !exists("did_install_syntax_menu") && &guioptions !~# "M" 2721 source <sfile>:p:h/menu.vim 2722endif 2723 2724" Function called for testing all functions defined here. These are 2725" script-local, thus need to be executed here. 2726" Returns a string with error messages (hopefully empty). 2727func! TestFiletypeFuncs(testlist) 2728 let output = '' 2729 for f in a:testlist 2730 try 2731 exe f 2732 catch 2733 let output = output . "\n" . f . ": " . v:exception 2734 endtry 2735 endfor 2736 return output 2737endfunc 2738 2739" Restore 'cpoptions' 2740let &cpo = s:cpo_save 2741unlet s:cpo_save 2742