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