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