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