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