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