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