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