1" Vim support file to detect file types 2" 3" Maintainer: Bram Moolenaar <[email protected]> 4" Last Change: 2005 Feb 18 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 19au BufNewFile,BufRead *.orig,*.bak,*.old,*.new,*.rpmsave,*.rpmnew 20 \ exe "doau filetypedetect BufRead " . expand("<afile>:r") 21au BufNewFile,BufRead *~ 22 \ let s:name = expand("<afile>") | 23 \ let s:short = substitute(s:name, '\~$', '', '') | 24 \ if s:name != s:short && s:short != "" | 25 \ exe "doau filetypedetect BufRead " . s:short | 26 \ endif | 27 \ unlet s:name | 28 \ unlet s:short 29au BufNewFile,BufRead *.in 30 \ if expand("<afile>:t") != "configure.in" | 31 \ exe "doau filetypedetect BufRead " . expand("<afile>:r") | 32 \ endif 33 34" Pattern used to match file names which should not be inspected. 35" Currently finds compressed files. 36if !exists("g:ft_ignore_pat") 37 let g:ft_ignore_pat = '\.\(Z\|gz\|bz2\|zip\|tgz\)$' 38endif 39 40" Abaqus or Trasys 41au BufNewFile,BufRead *.inp call FTCheck_inp() 42 43fun! FTCheck_inp() 44 if getline(1) =~ '^\*' 45 setf abaqus 46 else 47 let n = 1 48 if line("$") > 500 49 let nmax = 500 50 else 51 let nmax = line("$") 52 endif 53 while n <= nmax 54 if getline(n) =~? "^header surface data" 55 setf trasys 56 break 57 endif 58 let n = n + 1 59 endwhile 60 endif 61endfun 62 63" A-A-P recipe 64au BufNewFile,BufRead *.aap setf aap 65 66" ABAB/4 67au BufNewFile,BufRead *.abap setf abap 68 69" ABC music notation 70au BufNewFile,BufRead *.abc setf abc 71 72" ABEL 73au BufNewFile,BufRead *.abl setf abel 74 75" AceDB 76au BufNewFile,BufRead *.wrm setf acedb 77 78" Ada (83, 9X, 95) 79au BufNewFile,BufRead *.adb,*.ads,*.ada setf ada 80 81" AHDL 82au BufNewFile,BufRead *.tdf setf ahdl 83 84" AMPL 85au BufNewFile,BufRead *.run setf ampl 86 87" Ant 88au BufNewFile,BufRead build.xml setf ant 89 90" Apache style config file 91au BufNewFile,BufRead proftpd.conf* setf apachestyle 92 93" Apache config file 94au BufNewFile,BufRead httpd.conf*,srm.conf*,access.conf*,.htaccess,apache.conf* setf apache 95 96" XA65 MOS6510 cross assembler 97au BufNewFile,BufRead *.a65 setf a65 98 99" Applix ELF 100au BufNewFile,BufRead *.am 101 \ if expand("<afile>") !~? 'Makefile.am\>' | setf elf | endif 102 103" ALSA configuration 104au BufNewFile,BufRead ~/.asoundrc,/usr/share/alsa/alsa.conf,/etc/asound.conf setf alsaconf 105 106" Arc Macro Language 107au BufNewFile,BufRead *.aml setf aml 108 109" Arch Inventory file 110au BufNewFile,BufRead .arch-inventory,=tagging-method setf arch 111 112" ART*Enterprise (formerly ART-IM) 113au BufNewFile,BufRead *.art setf art 114 115" ASN.1 116au BufNewFile,BufRead *.asn,*.asn1 setf asn 117 118" Active Server Pages (with Visual Basic Script) 119au BufNewFile,BufRead *.asa 120 \ if exists("g:filetype_asa") | 121 \ exe "setf " . g:filetype_asa | 122 \ else | 123 \ setf aspvbs | 124 \ endif 125 126" Active Server Pages (with Perl or Visual Basic Script) 127au BufNewFile,BufRead *.asp 128 \ if exists("g:filetype_asp") | 129 \ exe "setf " . g:filetype_asp | 130 \ elseif getline(1) . getline(2) . getline(3) =~? "perlscript" | 131 \ setf aspperl | 132 \ else | 133 \ setf aspvbs | 134 \ endif 135 136" Grub (must be before catch *.lst) 137au BufNewFile,BufRead /boot/grub/menu.lst,/boot/grub/grub.conf setf grub 138 139" Assembly (all kinds) 140" *.lst is not pure assembly, it has two extra columns (address, byte codes) 141au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst call <SID>FTasm() 142 143" This function checks for the kind of assembly that is wanted by the user, or 144" can be detected from the first five lines of the file. 145fun! <SID>FTasm() 146 " make sure b:asmsyntax exists 147 if !exists("b:asmsyntax") 148 let b:asmsyntax = "" 149 endif 150 151 if b:asmsyntax == "" 152 call FTCheck_asmsyntax() 153 endif 154 155 " if b:asmsyntax still isn't set, default to asmsyntax or GNU 156 if b:asmsyntax == "" 157 if exists("g:asmsyntax") 158 let b:asmsyntax = g:asmsyntax 159 else 160 let b:asmsyntax = "asm" 161 endif 162 endif 163 164 exe "setf " . b:asmsyntax 165endfun 166 167fun! FTCheck_asmsyntax() 168 " see if file contains any asmsyntax=foo overrides. If so, change 169 " b:asmsyntax appropriately 170 let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4). 171 \" ".getline(5)." " 172 if head =~ '\sasmsyntax=\S\+\s' 173 let b:asmsyntax = substitute(head, '.*\sasmsyntax=\(\S\+\)\s.*','\1', "") 174 elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library')) 175 let b:asmsyntax = "vmasm" 176 endif 177endfun 178 179" Macro (VAX) 180au BufNewFile,BufRead *.mar setf vmasm 181 182" Atlas 183au BufNewFile,BufRead *.atl,*.as setf atlas 184 185" Automake 186au BufNewFile,BufRead [mM]akefile.am setf automake 187 188" Avenue 189au BufNewFile,BufRead *.ave setf ave 190 191" Awk 192au BufNewFile,BufRead *.awk setf awk 193 194" B 195au BufNewFile,BufRead *.mch,*.ref,*.imp setf b 196 197" BASIC or Visual Basic 198au BufNewFile,BufRead *.bas call <SID>FTVB("basic") 199 200" Check if one of the first five lines contains "VB_Name". In that case it is 201" probably a Visual Basic file. Otherwise it's assumed to be "alt" filetype. 202fun! <SID>FTVB(alt) 203 if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)' 204 setf vb 205 else 206 exe "setf " . a:alt 207 endif 208endfun 209 210" Visual Basic Script (close to Visual Basic) 211au BufNewFile,BufRead *.vbs,*.dsm,*.ctl setf vb 212 213" Batch file for MSDOS. 214au BufNewFile,BufRead *.bat,*.sys setf dosbatch 215" *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd. 216au BufNewFile,BufRead *.cmd 217 \ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif 218 219" Batch file for 4DOS 220au BufNewFile,BufRead *.btm call <SID>FTbtm() 221fun! <SID>FTbtm() 222 if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm 223 setf dosbatch 224 else 225 setf btm 226 endif 227endfun 228 229" BC calculator 230au BufNewFile,BufRead *.bc setf bc 231 232" BDF font 233au BufNewFile,BufRead *.bdf setf bdf 234 235" BibTeX bibliography database file 236au BufNewFile,BufRead *.bib setf bib 237 238" BIND configuration 239au BufNewFile,BufRead named.conf,rndc.conf setf named 240 241" BIND zone 242au BufNewFile,BufRead named.root setf bindzone 243 244" Blank 245au BufNewFile,BufRead *.bl setf blank 246 247" C or lpc 248au BufNewFile,BufRead *.c call <SID>FTlpc() 249 250fun! <SID>FTlpc() 251 if exists("g:lpc_syntax_for_c") 252 let lnum = 1 253 while lnum <= 12 254 if getline(lnum) =~# '^\(//\|inherit\|private\|protected\|nosave\|string\|object\|mapping\|mixed\)' 255 setf lpc 256 return 257 endif 258 let lnum = lnum + 1 259 endwhile 260 endif 261 setf c 262endfun 263 264" Calendar 265au BufNewFile,BufRead calendar,*/.calendar/*, 266 \*/share/calendar/*/calendar.*,*/share/calendar/calendar.* 267 \ setf calendar 268 269" C# 270au BufNewFile,BufRead *.cs setf cs 271 272" Comshare Dimension Definition Language 273au BufNewFile,BufRead *.cdl setf cdl 274 275" Controllable Regex Mutilator 276au BufNewFile,BufRead *.crm setf crm 277 278" Cyn++ 279au BufNewFile,BufRead *.cyn setf cynpp 280 281" Cynlib 282" .cc and .cpp files can be C++ or Cynlib. 283au BufNewFile,BufRead *.cc 284 \ if exists("cynlib_syntax_for_cc")|setf cynlib|else|setf cpp|endif 285au BufNewFile,BufRead *.cpp 286 \ if exists("cynlib_syntax_for_cpp")|setf cynlib|else|setf cpp|endif 287 288" C++ 289if has("fname_case") 290 au BufNewFile,BufRead *.cxx,*.c++,*.C,*.H,*.hh,*.hxx,*.hpp,*.moc,*.tcc,*.inl setf cpp 291else 292 au BufNewFile,BufRead *.cxx,*.c++,*.hh,*.hxx,*.hpp,*.moc,*.tcc,*.inl setf cpp 293endif 294 295" .h files can be C, Ch or C++, set c_syntax_for_h if you want C, 296" ch_syntax_for_h if you want Ch. 297au BufNewFile,BufRead *.h 298 \ if exists("c_syntax_for_h") | setf c | 299 \ elseif exists("ch_syntax_for_h") | setf ch | 300 \ else | setf cpp | endif 301 302" Ch (CHscript) 303au BufNewFile,BufRead *.chf setf ch 304 305" TLH files are C++ headers generated by Visual C++'s #import from typelibs 306au BufNewFile,BufRead *.tlh setf cpp 307 308" Cascading Style Sheets 309au BufNewFile,BufRead *.css setf css 310 311" Century Term Command Scripts (*.cmd too) 312au BufNewFile,BufRead *.con setf cterm 313 314" Changelog 315au BufNewFile,BufRead changelog.Debian,changelog.dch setf debchangelog 316au BufNewFile,BufRead [cC]hange[lL]og if getline(1) =~ '; urgency=' 317 \| setf debchangelog | else | setf changelog | endif 318 319" CHILL 320au BufNewFile,BufRead *..ch setf chill 321 322" Changes for WEB and CWEB or CHILL 323au BufNewFile,BufRead *.ch call <SID>FTchange() 324 325" This function checks if one of the first ten lines start with a '@'. In 326" that case it is probably a change file. 327" If the first line starts with # or ! it's probably a ch file. 328" If a line has "main", "include", "//" ir "/*" it's probably ch. 329" Otherwise CHILL is assumed. 330fun! <SID>FTchange() 331 let lnum = 1 332 while lnum <= 10 333 if getline(lnum)[0] == '@' 334 setf change 335 return 336 endif 337 if lnum == 1 && (getline(1)[0] == '#' || getline(1)[0] == '!') 338 setf ch 339 return 340 endif 341 if getline(lnum) =~ "MODULE" 342 setf chill 343 return 344 endif 345 if getline(lnum) =~ 'main\s*(\|#\s*include\|//' 346 setf ch 347 return 348 endif 349 let lnum = lnum + 1 350 endwhile 351 setf chill 352endfun 353 354" Clean 355au BufNewFile,BufRead *.dcl,*.icl setf clean 356 357" Clever 358au BufNewFile,BufRead *.eni setf cl 359 360" Clever or dtd 361au BufNewFile,BufRead *.ent call <SID>FTent() 362 363fun! <SID>FTent() 364 " This function checks for valid cl syntax in the first five lines. 365 " Look for either an opening comment, '#', or a block start, '{". 366 " If not found, assume SGML. 367 let lnum = 1 368 while lnum < 6 369 let line = getline(lnum) 370 if line =~ '^\s*[#{]' 371 setf cl 372 return 373 elseif line !~ '^\s*$' 374 " Not a blank line, not a comment, and not a block start, 375 " so doesn't look like valid cl code. 376 break 377 endif 378 let lnum = lnum + 1 379 endw 380 setf dtd 381endfun 382 383" Clipper (or FoxPro) 384au BufNewFile,BufRead *.prg 385 \ if exists("g:filetype_prg") | 386 \ exe "setf " . g:filetype_prg | 387 \ else | 388 \ setf clipper | 389 \ endif 390 391" Cobol 392au BufNewFile,BufRead *.cbl,*.cob,*.cpy,*.lib setf cobol 393 394" Cold Fusion 395au BufNewFile,BufRead *.cfm,*.cfi,*.cfc setf cf 396 397" Configure scripts 398au BufNewFile,BufRead configure.in,configure.ac setf config 399 400" WildPackets EtherPeek Decoder 401au BufNewFile,BufRead *.dcd setf dcd 402 403" Enlightenment configuration files 404au BufNewFile,BufRead *enlightenment/*.cfg setf c 405 406" Eterm 407au BufNewFile,BufRead *Eterm/*.cfg setf eterm 408 409" Lynx config files 410au BufNewFile,BufRead lynx.cfg setf lynx 411 412" Quake 413au BufNewFile,BufRead *baseq[2-3]/*.cfg,*id1/*.cfg setf quake 414au BufNewFile,BufRead *quake[1-3]/*.cfg setf quake 415 416" Quake C 417au BufNewFile,BufRead *.qc setf c 418 419" Configure files 420au BufNewFile,BufRead *.cfg setf cfg 421 422" Communicating Sequential Processes 423au BufNewFile,BufRead *.csp,*.fdr setf csp 424 425" CUPL logic description and simulation 426au BufNewFile,BufRead *.pld setf cupl 427au BufNewFile,BufRead *.si setf cuplsim 428 429" Debian Control 430au BufNewFile,BufRead */debian/control setf debcontrol 431 432" ROCKLinux package description 433au BufNewFile,BufRead *.desc setf desc 434 435" the D language 436au BufNewFile,BufRead *.d setf d 437 438" Desktop files 439au BufNewFile,BufRead *.desktop,.directory setf desktop 440 441" Diff files 442au BufNewFile,BufRead *.diff,*.rej,*.patch setf diff 443 444" Dircolors 445au BufNewFile,BufRead .dir_colors,/etc/DIR_COLORS setf dircolors 446 447" Diva (with Skill) or InstallShield 448au BufNewFile,BufRead *.rul 449 \ if getline(1).getline(2).getline(3).getline(4).getline(5).getline(6) =~? 'InstallShield' | 450 \ setf ishd | 451 \ else | 452 \ setf diva | 453 \ endif 454 455" DCL (Digital Command Language - vms) or DNS zone file 456au BufNewFile,BufRead *.com 457 \ if getline(1).getline(2) =~ '$ORIGIN\|$TTL\|IN\s*SOA' 458 \ || getline(1).getline(2).getline(3).getline(4) =~ 'BIND.*named' 459 \ | setf dns | else | setf dcl | endif 460 461" DOT 462au BufNewFile,BufRead *.dot setf dot 463 464" Dylan - lid files 465au BufNewFile,BufRead *.lid setf dylanlid 466 467" Dylan - intr files (melange) 468au BufNewFile,BufRead *.intr setf dylanintr 469 470" Dylan 471au BufNewFile,BufRead *.dylan setf dylan 472 473" Microsoft Module Definition 474au BufNewFile,BufRead *.def setf def 475 476" Dracula 477au BufNewFile,BufRead *.drac,*.drc,*lvs,*lpe setf dracula 478 479" dsl 480au BufNewFile,BufRead *.dsl setf dsl 481 482" DTD (Document Type Definition for XML) 483au BufNewFile,BufRead *.dtd setf dtd 484 485" EDIF (*.edf,*.edif,*.edn,*.edo) 486au BufNewFile,BufRead *.ed\(f\|if\|n\|o\) setf edif 487 488" Embedix Component Description 489au BufNewFile,BufRead *.ecd setf ecd 490 491" Eiffel or Specman 492au BufNewFile,BufRead *.e,*.E call FTCheck_e() 493 494" Elinks configuration 495au BufNewFile,BufRead */etc/elinks.conf,*/.elinks/elinks.conf setf elinks 496 497fun! FTCheck_e() 498 let n = 1 499 while n < 100 && n < line("$") 500 if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$" 501 setf specman 502 return 503 endif 504 let n = n + 1 505 endwhile 506 setf eiffel 507endfun 508 509" ERicsson LANGuage 510au BufNewFile,BufRead *.erl setf erlang 511 512" Elm Filter Rules file 513au BufNewFile,BufRead filter-rules setf elmfilt 514 515" ESMTP rc file 516au BufNewFile,BufRead *esmtprc setf esmtprc 517 518" ESQL-C 519au BufNewFile,BufRead *.ec,*.EC setf esqlc 520 521" Essbase script 522au BufNewFile,BufRead *.csc setf csc 523 524" Exim 525au BufNewFile,BufRead exim.conf setf exim 526 527" Expect 528au BufNewFile,BufRead *.exp setf expect 529 530" Exports 531au BufNewFile,BufRead exports setf exports 532 533" Fetchmail RC file 534au BufNewFile,BufRead .fetchmailrc setf fetchmail 535 536" Focus Executable 537au BufNewFile,BufRead *.fex,*.focexec setf focexec 538 539" Focus Master file (but not for auto.master) 540au BufNewFile,BufRead auto.master setf conf 541au BufNewFile,BufRead *.mas,*.master setf master 542 543" Forth 544au BufNewFile,BufRead *.fs,*.ft setf forth 545 546" Fortran 547au BufNewFile,BufRead *.f,*.F,*.for,*.fpp,*.FPP*.ftn,*.f77,*.F77,*.f90,*.F90,*.f95,*.F95 setf fortran 548 549" FStab 550au BufNewFile,BufRead fstab setf fstab 551 552" GDB command files 553au BufNewFile,BufRead .gdbinit setf gdb 554 555" GDMO 556au BufNewFile,BufRead *.mo,*.gdmo setf gdmo 557 558" Gedcom 559au BufNewFile,BufRead *.ged setf gedcom 560 561" Gkrellmrc 562au BufNewFile,BufRead gkrellmrc,gkrellmrc_? setf gkrellmrc 563 564" GP scripts (2.0 and onward) 565au BufNewFile,BufRead *.gp setf gp 566 567" GPG 568au BufNewFile,BufRead */.gnupg/options setf gpg 569au BufNewFile,BufRead */.gnupg/gpg.conf setf gpg 570au BufNewFile,BufRead /usr/**/gnupg/options.skel setf gpg 571 572" Gnuplot scripts 573au BufNewFile,BufRead *.gpi setf gnuplot 574 575" GrADS scripts 576au BufNewFile,BufRead *.gs setf grads 577 578" Groovy 579au BufNewFile,BufRead *.groovy setf groovy 580 581" GNU Server Pages 582au BufNewFile,BufRead *.gsp setf gsp 583 584" GTK RC 585au BufNewFile,BufRead .gtkrc,gtkrc setf gtkrc 586 587" Haskell 588au BufNewFile,BufRead *.hs setf haskell 589au BufNewFile,BufRead *.lhs setf lhaskell 590au BufNewFile,BufRead *.chs setf chaskell 591 592" Hercules 593au BufNewFile,BufRead *.vc,*.ev,*.rs,*.sum,*.errsum setf hercules 594 595" HEX (Intel) 596au BufNewFile,BufRead *.hex,*.h32 setf hex 597 598" Tilde (must be before HTML) 599au BufNewFile,BufRead *.t.html setf tilde 600 601" HTML (.shtml and .stm for server side, .rhtml for Ruby html) 602au BufNewFile,BufRead *.html,*.htm,*.shtml,*.rhtml,*.stm call <SID>FTCheck_html() 603 604" Distinguish between HTML and XHTML 605fun! <SID>FTCheck_html() 606 let n = 1 607 while n < 10 && n < line("$") 608 if getline(n) =~ '\<DTD\s\+XHTML\s' 609 setf xhtml 610 return 611 endif 612 let n = n + 1 613 endwhile 614 setf html 615endfun 616 617 618" HTML with M4 619au BufNewFile,BufRead *.html.m4 setf htmlm4 620 621" HTML Cheetah template 622au BufNewFile,BufRead *.tmpl setf htmlcheetah 623 624" Hyper Builder 625au BufNewFile,BufRead *.hb setf hb 626 627" Icon 628au BufNewFile,BufRead *.icn setf icon 629 630" IDL (Interface Description Language) 631au BufNewFile,BufRead *.idl call <SID>FTCheck_idl() 632 633" Distinguish between standard IDL and MS-IDL 634fun! <SID>FTCheck_idl() 635 let n = 1 636 while n < 50 && n < line("$") 637 if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"' 638 setf msidl 639 return 640 endif 641 let n = n + 1 642 endwhile 643 setf idl 644endfun 645 646" Microsoft IDL (Interface Description Language) Also *.idl 647" MOF = WMI (Windows Management Instrumentation) Managed Object Format 648au BufNewFile,BufRead *.odl,*.mof setf msidl 649 650" Icewm menu 651au BufNewFile,BufRead */.icewm/menu setf icemenu 652 653" IDL (Interactive Data Language) 654au BufNewFile,BufRead *.pro setf idlang 655 656" Inform 657au BufNewFile,BufRead .indent.pro setf indent 658 659" Inform 660au BufNewFile,BufRead *.inf,*.INF setf inform 661 662" Ipfilter 663au BufNewFile,BufRead ipf.conf,ipf.rules setf ipfilter 664 665" Informix 4GL (source - canonical, include file, I4GL+M4 preproc.) 666au BufNewFile,BufRead *.4gl,*.4gh,*.m4gl setf fgl 667 668" .INI file for MSDOS 669au BufNewFile,BufRead *.ini setf dosini 670 671" SysV Inittab 672au BufNewFile,BufRead inittab setf inittab 673 674" Inno Setup 675au BufNewFile,BufRead *.iss setf iss 676 677" JAL 678au BufNewFile,BufRead *.jal,*.JAL setf jal 679 680" Jam 681au BufNewFile,BufRead *.jpl,*.jpr setf jam 682 683" Java 684au BufNewFile,BufRead *.java,*.jav setf java 685 686" JavaCC 687au BufNewFile,BufRead *.jj,*.jjt setf javacc 688 689" JavaScript 690au BufNewFile,BufRead *.js,*.javascript setf javascript 691 692" Java Server Pages 693au BufNewFile,BufRead *.jsp setf jsp 694 695" Java Properties resource file (note: doesn't catch font.properties.pl) 696au BufNewFile,BufRead *.properties,*.properties_??,*.properties_??_??,*.properties_??_??_* setf jproperties 697 698" Jess 699au BufNewFile,BufRead *.clp setf jess 700 701" Jgraph 702au BufNewFile,BufRead *.jgr setf jgraph 703 704" Kixtart 705au BufNewFile,BufRead *.kix setf kix 706 707" Kimwitu[++] 708au BufNewFile,BufRead *.k setf kwt 709 710" KDE script 711au BufNewFile,BufRead *.ks setf kscript 712 713" Lace (ISE) 714au BufNewFile,BufRead *.ace,*.ACE setf lace 715 716" Latte 717au BufNewFile,BufRead *.latte,*.lte setf latte 718 719" LambdaProlog (*.mod too, see Modsim) 720au BufNewFile,BufRead *.sig setf lprolog 721 722" LDAP LDIF 723au BufNewFile,BufRead *.ldif setf ldif 724 725" Lex 726au BufNewFile,BufRead *.lex,*.l setf lex 727 728" Libao 729au BufNewFile,BufRead /etc/libao.conf,*/.libao setf libao 730 731" LFTP 732au BufNewFile,BufRead lftp.conf,.lftprc,*lftp/rc setf lftp 733 734" Lifelines (or Lex for C++!) 735au BufNewFile,BufRead *.ll setf lifelines 736 737" Lilo: Linux loader 738au BufNewFile,BufRead lilo.conf* setf lilo 739 740" Lisp (*.el = ELisp, *.cl = Common Lisp, *.jl = librep Lisp) 741if has("fname_case") 742 au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,*.L,.emacs,.sawfishrc setf lisp 743else 744 au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,.emacs,.sawfishrc setf lisp 745endif 746 747" Lite 748au BufNewFile,BufRead *.lite,*.lt setf lite 749 750" Logtalk 751au BufNewFile,BufRead *.lgt setf logtalk 752 753" LOTOS 754au BufNewFile,BufRead *.lot,*.lotos setf lotos 755 756" Lout (also: *.lt) 757au BufNewFile,BufRead *.lou,*.lout setf lout 758 759" Lua 760au BufNewFile,BufRead *.lua setf lua 761 762" Lynx style file (or LotusScript!) 763au BufNewFile,BufRead *.lss setf lss 764 765" M4 766au BufNewFile,BufRead *.m4 767 \ if expand("<afile>") !~? 'html.m4$\|fvwm2rc' | setf m4 | endif 768 769" MaGic Point 770au BufNewFile,BufRead *.mgp setf mgp 771 772" Mail (for Elm, trn, mutt, rn, slrn) 773au BufNewFile,BufRead snd.\d\+,.letter,.letter.\d\+,.followup,.article,.article.\d\+,pico.\d\+,mutt-*-\w\+,mutt\w\{6\},ae\d\+.txt,/tmp/SLRN[0-9A-Z.]\+,*.eml setf mail 774 775" Mailcap configuration file 776au BufNewFile,BufRead .mailcap,mailcap setf mailcap 777 778" Makefile 779au BufNewFile,BufRead *[mM]akefile,*.mk,*.mak,*.dsp setf make 780 781" MakeIndex 782au BufNewFile,BufRead *.ist,*.mst setf ist 783 784" Manpage 785au BufNewFile,BufRead *.man setf man 786 787" Maple V 788au BufNewFile,BufRead *.mv,*.mpl,*.mws setf maple 789 790" Mason 791au BufNewFile,BufRead *.mason,*.mhtml setf mason 792 793" Matlab or Objective C 794au BufNewFile,BufRead *.m call FTCheck_m() 795 796fun! FTCheck_m() 797 let n = 1 798 while n < 10 799 let line = getline(n) 800 if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)' 801 setf objc 802 return 803 endif 804 if line =~ '^\s*%' 805 setf matlab 806 return 807 endif 808 if line =~ '^\s*(\*' 809 setf mma 810 return 811 endif 812 let n = n + 1 813 endwhile 814 setf matlab 815endfun 816 817" Maya Extension Language 818au BufNewFile,BufRead *.mel setf mel 819 820" Metafont 821au BufNewFile,BufRead *.mf setf mf 822 823" MetaPost 824au BufNewFile,BufRead *.mp setf mp 825 826" MMIX or VMS makefile 827au BufNewFile,BufRead *.mms call FTCheck_mms() 828 829fun! FTCheck_mms() 830 let n = 1 831 while n < 10 832 let line = getline(n) 833 if line =~ '^\s*\(%\|//\)' || line =~ '^\*' 834 setf mmix 835 return 836 endif 837 if line =~ '^\s*#' 838 setf make 839 return 840 endif 841 let n = n + 1 842 endwhile 843 setf mmix 844endfun 845 846 847" Modsim III (or LambdaProlog) 848au BufNewFile,BufRead *.mod 849 \ if getline(1) =~ '\<module\>' | 850 \ setf lprolog | 851 \ else | 852 \ setf modsim3 | 853 \ endif 854 855" Modula 2 856au BufNewFile,BufRead *.m2,*.DEF,*.MOD,*.md,*.mi setf modula2 857 858" Modula 3 (.m3, .i3, .mg, .ig) 859au BufNewFile,BufRead *.[mi][3g] setf modula3 860 861" Monk 862au BufNewFile,BufRead *.isc,*.monk,*.ssc,*.tsc setf monk 863 864" MOO 865au BufNewFile,BufRead *.moo setf moo 866 867" Modconf 868au BufNewFile,BufRead /etc/modules.conf,/etc/conf.modules setf modconf 869au BufNewFile,BufRead /etc/modutils/* 870 \ if executable(expand("<afile>")) != 1 | setf modconf | endif 871 872" Mplayer config 873au BufNewFile,BufRead mplayer.conf,*/.mplayer/config setf mplayerconf 874 875" Moterola S record 876au BufNewFile,BufRead *.s19,*.s28,*.s37 setf srec 877 878" Msql 879au BufNewFile,BufRead *.msql setf msql 880 881" Mysql 882au BufNewFile,BufRead *.mysql setf mysql 883 884" M$ Resource files 885au BufNewFile,BufRead *.rc setf rc 886 887" MuPAD source 888au BufRead,BufNewFile *.mu setf mupad 889 890" Mush 891au BufNewFile,BufRead *.mush setf mush 892 893" Mutt setup file 894au BufNewFile,BufRead .muttrc*,*/.mutt/muttrc*,Muttrc setf muttrc 895 896" Nastran input/DMAP 897"au BufNewFile,BufRead *.dat setf nastran 898 899" Natural 900au BufNewFile,BufRead *.NS[ACGLMNPS] setf natural 901 902" Netrc 903au BufNewFile,BufRead .netrc setf netrc 904 905" Novell netware batch files 906au BufNewFile,BufRead *.ncf setf ncf 907 908" Nroff/Troff (*.ms and *.t are checked below) 909au BufNewFile,BufRead *.me 910 \ if expand("<afile>") != "read.me" && expand("<afile>") != "click.me" | 911 \ setf nroff | 912 \ endif 913au BufNewFile,BufRead *.tr,*.nr,*.roff,*.tmac,*.mom setf nroff 914au BufNewFile,BufRead *.[1-9] call <SID>FTnroff() 915 916" This function checks if one of the first five lines start with a dot. In 917" that case it is probably an nroff file: 'filetype' is set and 1 is returned. 918fun! <SID>FTnroff() 919 if getline(1)[0] . getline(2)[0] . getline(3)[0] . getline(4)[0] . getline(5)[0] =~ '\.' 920 setf nroff 921 return 1 922 endif 923 return 0 924endfun 925 926" Nroff or Objective C++ 927au BufNewFile,BufRead *.mm call <SID>FTcheck_mm() 928 929fun! <SID>FTcheck_mm() 930 let n = 1 931 while n < 10 932 let line = getline(n) 933 if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)' 934 setf objcpp 935 return 936 endif 937 let n = n + 1 938 endwhile 939 setf nroff 940endfun 941 942" Not Quite C 943au BufNewFile,BufRead *.nqc setf nqc 944 945" NSIS 946au BufNewFile,BufRead *.nsi setf nsis 947 948" OCAML 949au BufNewFile,BufRead *.ml,*.mli,*.mll,*.mly setf ocaml 950 951" Occam 952au BufNewFile,BufRead *.occ setf occam 953 954" Omnimark 955au BufNewFile,BufRead *.xom,*.xin setf omnimark 956 957" OpenROAD 958au BufNewFile,BufRead *.or setf openroad 959 960" OPL 961au BufNewFile,BufRead *.[Oo][Pp][Ll] setf opl 962 963" Oracle config file 964au BufNewFile,BufRead *.ora setf ora 965 966" Packet filter conf 967au BufNewFile,BufRead pf.conf setf pf 968 969" PApp 970au BufNewFile,BufRead *.papp,*.pxml,*.pxsl setf papp 971 972" Pascal (also *.p) 973au BufNewFile,BufRead *.pas setf pascal 974 975" Delphi project file 976au BufNewFile,BufRead *.dpr setf pascal 977 978" Perl 979if has("fname_case") 980 au BufNewFile,BufRead *.pl,*.PL call FTCheck_pl() 981else 982 au BufNewFile,BufRead *.pl call FTCheck_pl() 983endif 984au BufNewFile,BufRead *.plx setf perl 985 986fun! FTCheck_pl() 987 if exists("g:filetype_pl") 988 exe "setf " . g:filetype_pl 989 else 990 " recognize Prolog by specific text in the first non-empty line 991 " require a blank after the '%' because Perl uses "%list" and "%translate" 992 let l = getline(nextnonblank(1)) 993 if l =~ '\<prolog\>' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-' 994 setf prolog 995 else 996 setf perl 997 endif 998 endif 999endfun 1000 1001" Perl, XPM or XPM2 1002au BufNewFile,BufRead *.pm 1003 \ if getline(1) =~ "XPM2" | 1004 \ setf xpm2 | 1005 \ elseif getline(1) =~ "XPM" | 1006 \ setf xpm | 1007 \ else | 1008 \ setf perl | 1009 \ endif 1010 1011" Perl POD 1012au BufNewFile,BufRead *.pod setf pod 1013 1014" Php3 1015au BufNewFile,BufRead *.php,*.php3 setf php 1016 1017" Phtml 1018au BufNewFile,BufRead *.phtml setf phtml 1019 1020" Pike 1021au BufNewFile,BufRead *.pike,*.lpc,*.ulpc,*.pmod setf pike 1022 1023" Pinfo config 1024au BufNewFile,BufRead */etc/pinforc,*/.pinforc setf pinfo 1025 1026" Palm Resource compiler 1027au BufNewFile,BufRead *.rcp setf pilrc 1028 1029" Pine config 1030au BufNewFile,BufRead .pinerc,pinerc,.pinercex,pinercex setf pine 1031 1032" PL/M (also: *.inp) 1033au BufNewFile,BufRead *.plm,*.p36,*.pac setf plm 1034 1035" PL/SQL 1036au BufNewFile,BufRead *.pls,*.plsql setf plsql 1037 1038" PLP 1039au BufNewFile,BufRead *.plp setf plp 1040 1041" PO and PO template (GNU gettext) 1042au BufNewFile,BufRead *.po,*.pot setf po 1043 1044" Postfix main config 1045au BufNewFile,BufRead main.cf setf pfmain 1046 1047" PostScript (+ font files, encapsulated PostScript, Adobe Illustrator) 1048au BufNewFile,BufRead *.ps,*.pfa,*.afm,*.eps,*.epsf,*.epsi,*.ai setf postscr 1049 1050" PostScript Printer Description 1051au BufNewFile,BufRead *.ppd setf ppd 1052 1053" Povray 1054au BufNewFile,BufRead *.pov setf pov 1055 1056" Povray configuration 1057au BufNewFile,BufRead .povrayrc setf povini 1058 1059" Povray, PHP or assembly 1060au BufNewFile,BufRead *.inc call FTCheck_inc() 1061 1062fun! FTCheck_inc() 1063 if exists("g:filetype_inc") 1064 exe "setf " . g:filetype_inc 1065 else 1066 let lines = getline(1).getline(2).getline(3) 1067 if lines =~? "perlscript" 1068 setf aspperl 1069 elseif lines =~ "<%" 1070 setf aspvbs 1071 elseif lines =~ "<?" 1072 setf php 1073 else 1074 call FTCheck_asmsyntax() 1075 if exists("b:asmsyntax") 1076 exe "setf " . b:asmsyntax 1077 else 1078 setf pov 1079 endif 1080 endif 1081 endif 1082endfun 1083 1084" Printcap and Termcap 1085au BufNewFile,BufRead *printcap 1086 \ let b:ptcap_type = "print" | setf ptcap 1087au BufNewFile,BufRead *termcap 1088 \ let b:ptcap_type = "term" | setf ptcap 1089 1090" PCCTS / ANTRL 1091"au BufNewFile,BufRead *.g setf antrl 1092au BufNewFile,BufRead *.g setf pccts 1093 1094" PPWizard 1095au BufNewFile,BufRead *.it,*.ih setf ppwiz 1096 1097" Oracle Pro*C/C++ 1098au BufNewFile,BufRead .pc setf proc 1099 1100" Procmail 1101au BufNewFile,BufRead .procmail,.procmailrc setf procmail 1102 1103" Progress or CWEB 1104au BufNewFile,BufRead *.w call <SID>FTprogress_cweb() 1105 1106function! <SID>FTprogress_cweb() 1107 if exists("g:filetype_w") 1108 exe "setf " . g:filetype_w 1109 return 1110 endif 1111 if getline(1) =~ '&ANALYZE' || getline(3) =~ '&GLOBAL-DEFINE' 1112 setf progress 1113 else 1114 setf cweb 1115 endif 1116endfun 1117 1118" Progress or assembly 1119au BufNewFile,BufRead *.i call <SID>FTprogress_asm() 1120 1121function! <SID>FTprogress_asm() 1122 if exists("g:filetype_i") 1123 exe "setf " . g:filetype_i 1124 return 1125 endif 1126 " This function checks for an assembly comment the first ten lines. 1127 " If not found, assume Progress. 1128 let lnum = 1 1129 while lnum <= 10 1130 let line = getline(lnum) 1131 if line =~ '^\s*;' || line =~ '^\*' 1132 call FTCheck_asm() 1133 return 1134 elseif line !~ '^\s*$' || line =~ '^/\*' 1135 " Not an empty line: Doesn't look like valid assembly code. 1136 " Or it looks like a Progress /* comment 1137 break 1138 endif 1139 let lnum = lnum + 1 1140 endw 1141 setf progress 1142endfun 1143 1144" Progress or Pascal 1145au BufNewFile,BufRead *.p call <SID>FTprogress_pascal() 1146 1147function! <SID>FTprogress_pascal() 1148 if exists("g:filetype_p") 1149 exe "setf " . g:filetype_p 1150 return 1151 endif 1152 " This function checks for valid Pascal syntax in the first ten lines. 1153 " Look for either an opening comment or a program start. 1154 " If not found, assume Progress. 1155 let lnum = 1 1156 while lnum <= 10 1157 let line = getline(lnum) 1158 if line =~ '^\s*\(program\|procedure\|function\|const\|type\|var\)\>' 1159 \ || line =~ '^\s*{' || line =~ '^\s*(\*' 1160 setf pascal 1161 return 1162 elseif line !~ '^\s*$' || line =~ '^/\*' 1163 " Not an empty line: Doesn't look like valid Pascal code. 1164 " Or it looks like a Progress /* comment 1165 break 1166 endif 1167 let lnum = lnum + 1 1168 endw 1169 setf progress 1170endfun 1171 1172 1173" Software Distributor Product Specification File (POSIX 1387.2-1995) 1174au BufNewFile,BufRead *.psf setf psf 1175au BufNewFile,BufRead INDEX,INFO 1176 \ if getline(1) =~ '^\s*\(distribution\|installed_software\|root\|bundle\|product\)\s*$' | 1177 \ setf psf | 1178 \ endif 1179 1180" Prolog 1181au BufNewFile,BufRead *.pdb setf prolog 1182 1183" Pyrex 1184au BufNewFile,BufRead *.pyx,*.pxd setf pyrex 1185 1186" Python 1187au BufNewFile,BufRead *.py,*.pyw setf python 1188 1189" Radiance 1190au BufNewFile,BufRead *.rad,*.mat setf radiance 1191 1192" Ratpoison config/command files 1193au BufNewFile,BufRead .ratpoisonrc,ratpoisonrc setf ratpoison 1194 1195" RCS file 1196au BufNewFile,BufRead *\,v setf rcs 1197 1198" Readline 1199au BufNewFile,BufRead .inputrc setf readline 1200 1201" Registry for MS-Windows 1202au BufNewFile,BufRead *.reg 1203 \ if getline(1) =~? '^REGEDIT[0-9]*\s*$\|^Windows Registry Editor Version \d*\.\d*\s*$' | setf registry | endif 1204 1205" Renderman Interface Bytestream 1206au BufNewFile,BufRead *.rib setf rib 1207 1208" Rexx 1209au BufNewFile,BufRead *.rexx,*.rex setf rexx 1210 1211" R (Splus) 1212au BufNewFile,BufRead *.s,*.S setf r 1213 1214" Rexx, Rebol or R 1215au BufNewFile,BufRead *.r,*.R call <SID>FTCheck_r() 1216 1217fun! <SID>FTCheck_r() 1218 if getline(1) =~ '^REBOL' 1219 setf rebol 1220 else 1221 let n = 1 1222 let max = line("$") 1223 if max > 50 1224 let max = 50 1225 endif 1226 while n < max 1227 " R has # comments 1228 if getline(n) =~ '^\s*#' 1229 setf r 1230 break 1231 endif 1232 " Rexx has /* comments */ 1233 if getline(n) =~ '^\s*/\*' 1234 setf rexx 1235 break 1236 endif 1237 let n = n + 1 1238 endwhile 1239 if n >= max 1240 setf rexx 1241 endif 1242 endif 1243endfun 1244 1245" Remind 1246au BufNewFile,BufRead .reminders* setf remind 1247 1248" Resolv.conf 1249au BufNewFile,BufRead resolv.conf setf resolv 1250 1251" Relax NG Compact 1252au BufNewFile,BufRead *.rnc setf rnc 1253 1254" RPL/2 1255au BufNewFile,BufRead *.rpl setf rpl 1256 1257" Robots.txt 1258au BufNewFile,BufRead robots.txt setf robots 1259 1260" Rpcgen 1261au BufNewFile,BufRead *.x setf rpcgen 1262 1263" reStructuredText Documentation Format 1264au BufNewFile,BufRead *.rst setf rst 1265 1266" RTF 1267au BufNewFile,BufRead *.rtf setf rtf 1268 1269" Ruby 1270au BufNewFile,BufRead *.rb,*.rbw,*.gem,*.gemspec setf ruby 1271 1272" S-lang (or shader language!) 1273au BufNewFile,BufRead *.sl setf slang 1274 1275" Samba config 1276au BufNewFile,BufRead smb.conf setf samba 1277 1278" SAS script 1279au BufNewFile,BufRead *.sas setf sas 1280 1281" Sather 1282au BufNewFile,BufRead *.sa setf sather 1283 1284" Scilab 1285au BufNewFile,BufRead *.sci setf scilab 1286 1287" SDL 1288au BufNewFile,BufRead *.sdl,*.pr setf sdl 1289 1290" sed 1291au BufNewFile,BufRead *.sed setf sed 1292 1293" Sieve (RFC 3028) 1294au BufNewFile,BufRead *.siv setf sieve 1295 1296" Sendmail 1297au BufNewFile,BufRead sendmail.cf setf sm 1298 1299" Sendmail .mc files are actually m4 1300au BufNewFile,BufRead *.mc setf m4 1301 1302" SGML 1303au BufNewFile,BufRead *.sgm,*.sgml 1304 \ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'linuxdoc' | 1305 \ setf sgmllnx | 1306 \ elseif getline(1) =~ '<!DOCTYPE.*DocBook' || getline(2) =~ '<!DOCTYPE.*DocBook' | 1307 \ let b:docbk_type="sgml" | 1308 \ setf docbk | 1309 \ else | 1310 \ setf sgml | 1311 \ endif 1312 1313" SGMLDECL 1314au BufNewFile,BufRead *.decl,*.dcl,*.dec 1315 \ if getline(1).getline(2).getline(3) =~? '^<!SGML' | 1316 \ setf sgmldecl | 1317 \ endif 1318 1319" SGML catalog file 1320au BufNewFile,BufRead sgml.catalog*,catalog setf catalog 1321 1322" Shell scripts (sh, ksh, bash, bash2, csh); Allow .profile_foo etc. 1323" Gentoo ebuilds are actually bash scripts 1324au BufNewFile,BufRead .bashrc*,bashrc,bash.bashrc,.bash_profile*,.bash_logout*,*.bash,*.ebuild call SetFileTypeSH("bash") 1325au BufNewFile,BufRead .kshrc*,*.ksh call SetFileTypeSH("ksh") 1326au BufNewFile,BufRead /etc/profile,.profile*,*.sh,*.env call SetFileTypeSH(getline(1)) 1327 1328fun! SetFileTypeSH(name) 1329 if a:name =~ '\<ksh\>' 1330 let b:is_kornshell = 1 1331 if exists("b:is_bash") 1332 unlet b:is_bash 1333 endif 1334 if exists("b:is_sh") 1335 unlet b:is_sh 1336 endif 1337 elseif exists("g:bash_is_sh") || a:name =~ '\<bash\>' || a:name =~ '\<bash2\>' 1338 let b:is_bash = 1 1339 if exists("b:is_kornshell") 1340 unlet b:is_kornshell 1341 endif 1342 if exists("b:is_sh") 1343 unlet b:is_sh 1344 endif 1345 elseif a:name =~ '\<sh\>' 1346 let b:is_sh = 1 1347 if exists("b:is_kornshell") 1348 unlet b:is_kornshell 1349 endif 1350 if exists("b:is_bash") 1351 unlet b:is_bash 1352 endif 1353 endif 1354 call SetFileTypeShell("sh") 1355endfun 1356 1357" For shell-like file types, check for an "exec" command hidden in a comment, 1358" as used for Tcl. 1359fun! SetFileTypeShell(name) 1360 let l = 2 1361 while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)' 1362 " Skip empty and comment lines. 1363 let l = l + 1 1364 endwhile 1365 if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$' 1366 " Found an "exec" line after a comment with continuation 1367 let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '') 1368 if n =~ '\<tclsh\|\<wish' 1369 setf tcl 1370 return 1371 endif 1372 endif 1373 exe "setf " . a:name 1374endfun 1375 1376" tcsh scripts 1377au BufNewFile,BufRead .tcshrc*,*.tcsh,tcsh.tcshrc,tcsh.login call SetFileTypeShell("tcsh") 1378 1379" csh scripts, but might also be tcsh scripts (on some systems csh is tcsh) 1380au BufNewFile,BufRead .login*,.cshrc*,csh.cshrc,csh.login,csh.logout,*.csh,.alias call SetFileTypeCSH() 1381 1382fun! SetFileTypeCSH() 1383 if exists("g:filetype_csh") 1384 call SetFileTypeShell(g:filetype_csh) 1385 elseif &shell =~ "tcsh" 1386 call SetFileTypeShell("tcsh") 1387 else 1388 call SetFileTypeShell("csh") 1389 endif 1390endfun 1391 1392" Z-Shell script 1393au BufNewFile,BufRead .zsh*,.zlog*,.zprofile,/etc/zprofile,.zfbfmarks,.zcompdump* setf zsh 1394 1395" Scheme 1396au BufNewFile,BufRead *.scm,*.ss setf scheme 1397 1398" Screen RC 1399au BufNewFile,BufRead .screenrc,screenrc setf screen 1400 1401" Simula 1402au BufNewFile,BufRead *.sim setf simula 1403 1404" SINDA 1405au BufNewFile,BufRead *.sin,*.s85 setf sinda 1406 1407" SKILL 1408au BufNewFile,BufRead *.il setf skill 1409 1410" SLRN 1411au BufNewFile,BufRead .slrnrc setf slrnrc 1412au BufNewFile,BufRead *.score setf slrnsc 1413 1414" Smalltalk 1415au BufNewFile,BufRead *.st,*.cls setf st 1416 1417" Smarty templates 1418au BufNewFile,BufRead *.tpl setf smarty 1419 1420" SMIL or XML 1421au BufNewFile,BufRead *.smil 1422 \ if getline(1) =~ '<?\s*xml.*?>' | 1423 \ setf xml | 1424 \ else | 1425 \ setf smil | 1426 \ endif 1427 1428" SMIL or SNMP MIB file 1429au BufNewFile,BufRead *.smi 1430 \ if getline(1) =~ '\<smil\>' | 1431 \ setf smil | 1432 \ else | 1433 \ setf mib | 1434 \ endif 1435 1436" SMITH 1437au BufNewFile,BufRead *.smt,*.smith setf smith 1438 1439" Snobol4 1440au BufNewFile,BufRead *.sno setf snobol4 1441 1442" SNMP MIB files 1443au BufNewFile,BufRead *.mib,*.my setf mib 1444 1445" Snort Configuration 1446au BufNewFile,BufRead *.hog,snort.conf,vision.conf,*.rules setf hog 1447 1448" Spec (Linux RPM) 1449au BufNewFile,BufRead *.spec setf spec 1450 1451" Speedup (AspenTech plant simulator) 1452au BufNewFile,BufRead *.speedup,*.spdata,*.spd setf spup 1453 1454" Slice 1455au BufNewFile,BufRead *.ice setf slice 1456 1457" Spice 1458au BufNewFile,BufRead *.sp,*.spice setf spice 1459 1460" Spyce 1461au BufNewFile,BufRead *.spy,*.spi setf spyce 1462 1463" Squid 1464au BufNewFile,BufRead squid.conf setf squid 1465 1466" SQL for Oracle Designer 1467au BufNewFile,BufRead *.tyb,*.typ,*.tyc,*.pkb,*.pks setf sql 1468 1469" SQL 1470au BufNewFile,BufRead *.sql call SetFileTypeSQL() 1471 1472fun! SetFileTypeSQL() 1473 if exists("g:filetype_sql") 1474 exe "setf " . g:filetype_sql 1475 else 1476 setf sql 1477 endif 1478endfun 1479 1480" SQLJ 1481au BufNewFile,BufRead *.sqlj setf sqlj 1482 1483" SQR 1484au BufNewFile,BufRead *.sqr,*.sqi setf sqr 1485 1486" OpenSSH configuration 1487au BufNewFile,BufRead ssh_config,*/.ssh/config setf sshconfig 1488 1489" OpenSSH server configuration 1490au BufNewFile,BufRead sshd_config setf sshdconfig 1491 1492" Stored Procedures 1493au BufNewFile,BufRead *.stp setf stp 1494 1495" Standard ML 1496au BufNewFile,BufRead *.sml setf sml 1497 1498" Sudoers 1499au BufNewFile,BufRead /etc/sudoers,sudoers.tmp setf sudoers 1500 1501" Tads (or Nroff) 1502au BufNewFile,BufRead *.t 1503 \ if !<SID>FTnroff() | setf tads | endif 1504 1505" Tags 1506au BufNewFile,BufRead tags setf tags 1507 1508" TAK 1509au BufNewFile,BufRead *.tak setf tak 1510 1511" Tcl 1512au BufNewFile,BufRead *.tcl,*.tk,*.itcl,*.itk setf tcl 1513 1514" TealInfo 1515au BufNewFile,BufRead *.tli setf tli 1516 1517" Telix Salt 1518au BufNewFile,BufRead *.slt setf tsalt 1519 1520" Terminfo 1521au BufNewFile,BufRead *.ti setf terminfo 1522 1523" TeX 1524au BufNewFile,BufRead *.tex,*.latex,*.sty,*.dtx,*.ltx,*.bbl setf tex 1525 1526" Texinfo 1527au BufNewFile,BufRead *.texinfo,*.texi,*.txi setf texinfo 1528 1529" TeX configuration 1530au BufNewFile,BufRead texmf.cnf setf texmf 1531 1532" Tidy config 1533au BufNewFile,BufRead .tidyrc,tidyrc setf tidy 1534 1535" TF mud client 1536au BufNewFile,BufRead *.tf,.tfrc,tfrc setf tf 1537 1538" TPP - Text Presentation Program 1539au BufNewFile,BufReadPost *.tpp setf tpp 1540 1541" TSS - Geometry 1542au BufNewFile,BufReadPost *.tssgm setf tssgm 1543 1544" TSS - Optics 1545au BufNewFile,BufReadPost *.tssop setf tssop 1546 1547" TSS - Command Line (temporary) 1548au BufNewFile,BufReadPost *.tsscl setf tsscl 1549 1550" Motif UIT/UIL files 1551au BufNewFile,BufRead *.uit,*.uil setf uil 1552 1553" UnrealScript 1554au BufNewFile,BufRead *.uc setf uc 1555 1556" Verilog HDL 1557au BufNewFile,BufRead *.v setf verilog 1558 1559" VHDL 1560au BufNewFile,BufRead *.hdl,*.vhd,*.vhdl,*.vhdl_[0-9]*,*.vbe,*.vst setf vhdl 1561 1562" Vim script 1563au BufNewFile,BufRead *.vim,.exrc,_exrc setf vim 1564 1565" Viminfo file 1566au BufNewFile,BufRead .viminfo,_viminfo setf viminfo 1567 1568" Virata Config Script File 1569au BufRead,BufNewFile *.hw,*.module,*.pkg setf virata 1570 1571" Visual Basic (also uses *.bas) or FORM 1572au BufNewFile,BufRead *.frm call <SID>FTVB("form") 1573 1574" SaxBasic is close to Visual Basic 1575au BufNewFile,BufRead *.sba setf vb 1576 1577" Vgrindefs file 1578au BufNewFile,BufRead vgrindefs setf vgrindefs 1579 1580" VRML V1.0c 1581au BufNewFile,BufRead *.wrl setf vrml 1582 1583" Webmacro 1584au BufNewFile,BufRead *.wm setf webmacro 1585 1586" Wget config 1587au BufNewFile,BufRead .wgetrc,wgetrc setf wget 1588 1589" Website MetaLanguage 1590au BufNewFile,BufRead *.wml setf wml 1591 1592" Winbatch 1593au BufNewFile,BufRead *.wbt setf winbatch 1594 1595" WvDial 1596au BufNewFile,BufRead wvdial.conf,.wvdialrc setf wvdial 1597 1598" CVS RC file 1599au BufNewFile,BufRead .cvsrc setf cvsrc 1600 1601" CVS commit file 1602au BufNewFile,BufRead cvs\d\+ setf cvs 1603 1604" WEB (*.web is also used for Winbatch: Guess, based on expecting "%" comment 1605" lines in a WEB file). 1606au BufNewFile,BufRead *.web 1607 \ if getline(1)[0].getline(2)[0].getline(3)[0].getline(4)[0].getline(5)[0] =~ "%" | 1608 \ setf web | 1609 \ else | 1610 \ setf winbatch | 1611 \ endif 1612 1613" Windows Scripting Host and Windows Script Component 1614au BufNewFile,BufRead *.ws[fc] setf wsh 1615 1616" X Pixmap (dynamically sets colors, use BufEnter to make it work better) 1617au BufEnter *.xpm 1618 \ if getline(1) =~ "XPM2" | 1619 \ setf xpm2 | 1620 \ else | 1621 \ setf xpm | 1622 \ endif 1623au BufEnter *.xpm2 setf xpm2 1624 1625" XFree86 config 1626au BufNewFile,BufRead XF86Config 1627 \ if getline(1) =~ '\<XConfigurator\>' | 1628 \ let b:xf86c_xfree86_version = 3 | 1629 \ endif | 1630 \ setf xf86conf 1631 1632" Xorg config 1633au BufNewFile,BufRead xorg.conf,xorg.conf-4 let b:xf86c_xfree86_version = 4 | setf xf86conf 1634 1635" XS Perl extension interface language 1636au BufNewFile,BufRead *.xs setf xs 1637 1638" X resources file 1639au BufNewFile,BufRead .Xdefaults,.Xpdefaults,.Xresources,xdm-config,*.ad setf xdefaults 1640 1641" Xmath 1642au BufNewFile,BufRead *.msc,*.msf setf xmath 1643au BufNewFile,BufRead *.ms 1644 \ if !<SID>FTnroff() | setf xmath | endif 1645 1646" XML 1647au BufNewFile,BufRead *.xml 1648 \ if getline(1) . getline(2) . getline(3) =~ '<!DOCTYPE.*DocBook' | 1649 \ let b:docbk_type="xml" | 1650 \ setf docbk | 1651 \ else | 1652 \ setf xml | 1653 \ endif 1654 1655" XMI (holding UML models) is also XML 1656au BufNewFile,BufRead *.xmi setf xml 1657 1658" CSPROJ files are Visual Studio.NET's XML-based project config files 1659au BufNewFile,BufRead *.csproj,*.csproj.user setf xml 1660 1661" Qt Linguist translation source and Qt User Interface Files are XML 1662au BufNewFile,BufRead *.ts,*.ui setf xml 1663 1664" XSD 1665au BufNewFile,BufRead *.xsd setf xsd 1666 1667" Xslt 1668au BufNewFile,BufRead *.xsl,*.xslt setf xslt 1669 1670" Yacc 1671au BufNewFile,BufRead *.y,*.yy setf yacc 1672 1673" Yaml 1674au BufNewFile,BufRead *.yaml,*.yml setf yaml 1675 1676" Z80 assembler asz80 1677au BufNewFile,BufRead *.z8a setf z8a 1678 1679augroup END 1680 1681 1682" Source the user-specified filetype file, for backwards compatibility with 1683" Vim 5.x. 1684if exists("myfiletypefile") && file_readable(expand(myfiletypefile)) 1685 execute "source " . myfiletypefile 1686endif 1687 1688 1689" Check for "*" after loading myfiletypefile, so that scripts.vim is only used 1690" when there are no matching file name extensions. 1691" Don't do this for compressed files. 1692augroup filetypedetect 1693au BufNewFile,BufRead * 1694 \ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat 1695 \ | runtime! scripts.vim | endif 1696au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif 1697 1698 1699" Extra checks for when no filetype has been detected now. Mostly used for 1700" patterns that end in "*". E.g., "zsh*" matches "zsh.vim", but that's a Vim 1701" script file. 1702 1703" BIND zone 1704au BufNewFile,BufRead /var/named/* setf bindzone 1705 1706" Changelog 1707au BufNewFile,BufRead [cC]hange[lL]og* if getline(1) =~ '; urgency=' 1708 \| setf debchangelog | else | setf changelog | endif 1709 1710" Crontab 1711au BufNewFile,BufRead crontab,crontab.* setf crontab 1712 1713" Dracula 1714au BufNewFile,BufRead drac.* setf dracula 1715 1716" Fvwm 1717au BufNewFile,BufRead *fvwmrc*,*fvwm95*.hook 1718 \ let b:fvwm_version = 1 | setf fvwm 1719au BufNewFile,BufRead *fvwm2rc* 1720 \ if expand("<afile>:e") == "m4" | setf fvwm2m4 | else | 1721 \ let b:fvwm_version = 2 | setf fvwm | endif 1722 1723" GTK RC 1724au BufNewFile,BufRead .gtkrc*,gtkrc* setf gtkrc 1725 1726" Jam 1727au BufNewFile,BufRead Prl*.*,JAM*.* setf jam 1728 1729" Jargon 1730au! BufNewFile,BufRead *jarg* 1731 \ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'THIS IS THE JARGON FILE' | 1732 \ setf jargon | 1733 \ endif 1734 1735" Makefile 1736au BufNewFile,BufRead [mM]akefile* setf make 1737 1738" Ruby Makefile 1739au BufNewFile,BufRead [rR]akefile* setf ruby 1740 1741" Mutt setup file 1742au BufNewFile,BufRead muttrc*,Muttrc* setf muttrc 1743 1744" Nroff macros 1745au BufNewFile,BufRead tmac.* setf nroff 1746 1747" Printcap and Termcap 1748au BufNewFile,BufRead *printcap* 1749 \ if !did_filetype() | let b:ptcap_type = "print" | setf ptcap | endif 1750au BufNewFile,BufRead *termcap* 1751 \ if !did_filetype() | let b:ptcap_type = "term" | setf ptcap | endif 1752 1753" Vim script 1754au BufNewFile,BufRead *vimrc* setf vim 1755 1756" Subversion commit file 1757au BufNewFile,BufRead svn-commit*.tmp setf svn 1758 1759" X resources file 1760au BufNewFile,BufRead Xresources*,*/app-defaults/*,*/Xresources/* setf xdefaults 1761 1762" XFree86 config 1763au BufNewFile,BufRead XF86Config-4* 1764 \ let b:xf86c_xfree86_version = 4 | setf xf86conf 1765au BufNewFile,BufRead XF86Config* 1766 \ if getline(1) =~ '\<XConfigurator\>' | 1767 \ let b:xf86c_xfree86_version = 3 | 1768 \ endif | 1769 \ setf xf86conf 1770 1771" X11 xmodmap 1772au BufNewFile,BufRead *xmodmap* setf xmodmap 1773 1774" Z-Shell script 1775au BufNewFile,BufRead zsh*,zlog* setf zsh 1776 1777 1778" Generic configuration file (check this last, it's just guessing!) 1779au BufNewFile,BufRead,StdinReadPost * 1780 \ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat 1781 \ && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#' 1782 \ || getline(4) =~ '^#' || getline(5) =~ '^#') | 1783 \ setf conf | 1784 \ endif 1785 1786" Use the plugin-filetype checks last, they may overrule any of the previously 1787" detected filetypes. 1788runtime! ftdetect/*.vim 1789 1790augroup END 1791 1792 1793" If the GUI is already running, may still need to install the Syntax menu. 1794" Don't do it when the 'M' flag is included in 'guioptions'. 1795if has("menu") && has("gui_running") 1796 \ && !exists("did_install_syntax_menu") && &guioptions !~# "M" 1797 source <sfile>:p:h/menu.vim 1798endif 1799 1800" Restore 'cpoptions' 1801let &cpo = s:cpo_save 1802unlet s:cpo_save 1803