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