1" Vim support file to detect file types 2" 3" Maintainer: Bram Moolenaar <[email protected]> 4" Last Change: 2006 Feb 23 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" MGL 895au BufNewFile,BufRead *.mgl setf mgl 896 897" MMIX or VMS makefile 898au BufNewFile,BufRead *.mms call s:FTmms() 899 900fun! s:FTmms() 901 let n = 1 902 while n < 10 903 let line = getline(n) 904 if line =~ '^\s*\(%\|//\)' || line =~ '^\*' 905 setf mmix 906 return 907 endif 908 if line =~ '^\s*#' 909 setf make 910 return 911 endif 912 let n = n + 1 913 endwhile 914 setf mmix 915endfun 916 917 918" Modsim III (or LambdaProlog) 919au BufNewFile,BufRead *.mod 920 \ if getline(1) =~ '\<module\>' | 921 \ setf lprolog | 922 \ else | 923 \ setf modsim3 | 924 \ endif 925 926" Modula 2 927au BufNewFile,BufRead *.m2,*.DEF,*.MOD,*.md,*.mi setf modula2 928 929" Modula 3 (.m3, .i3, .mg, .ig) 930au BufNewFile,BufRead *.[mi][3g] setf modula3 931 932" Monk 933au BufNewFile,BufRead *.isc,*.monk,*.ssc,*.tsc setf monk 934 935" MOO 936au BufNewFile,BufRead *.moo setf moo 937 938" Modconf 939au BufNewFile,BufRead /etc/modules.conf,/etc/conf.modules setf modconf 940au BufNewFile,BufRead /etc/modutils/* 941 \ if executable(expand("<afile>")) != 1 942 \| call s:StarSetf('modconf') 943 \|endif 944 945" Mplayer config 946au BufNewFile,BufRead mplayer.conf,*/.mplayer/config setf mplayerconf 947 948" Moterola S record 949au BufNewFile,BufRead *.s19,*.s28,*.s37 setf srec 950 951" Msql 952au BufNewFile,BufRead *.msql setf msql 953 954" Mysql 955au BufNewFile,BufRead *.mysql setf mysql 956 957" M$ Resource files 958au BufNewFile,BufRead *.rc setf rc 959 960" MuPAD source 961au BufRead,BufNewFile *.mu setf mupad 962 963" Mush 964au BufNewFile,BufRead *.mush setf mush 965 966" Mutt setup file 967au BufNewFile,BufRead Mutt{ng,}rc setf muttrc 968au BufNewFile,BufRead .mutt{ng,}rc*,*/.mutt{ng,}/mutt{ng,}rc* call s:StarSetf('muttrc') 969 970" Nano 971au BufNewFile,BufRead /etc/nanorc,.nanorc setf nanorc 972 973" Nastran input/DMAP 974"au BufNewFile,BufRead *.dat setf nastran 975 976" Natural 977au BufNewFile,BufRead *.NS[ACGLMNPS] setf natural 978 979" Netrc 980au BufNewFile,BufRead .netrc setf netrc 981 982" Novell netware batch files 983au BufNewFile,BufRead *.ncf setf ncf 984 985" Nroff/Troff (*.ms and *.t are checked below) 986au BufNewFile,BufRead *.me 987 \ if expand("<afile>") != "read.me" && expand("<afile>") != "click.me" | 988 \ setf nroff | 989 \ endif 990au BufNewFile,BufRead *.tr,*.nr,*.roff,*.tmac,*.mom setf nroff 991au BufNewFile,BufRead *.[1-9] call s:FTnroff() 992 993" This function checks if one of the first five lines start with a dot. In 994" that case it is probably an nroff file: 'filetype' is set and 1 is returned. 995fun! s:FTnroff() 996 if getline(1)[0] . getline(2)[0] . getline(3)[0] . getline(4)[0] . getline(5)[0] =~ '\.' 997 setf nroff 998 return 1 999 endif 1000 return 0 1001endfun 1002 1003" Nroff or Objective C++ 1004au BufNewFile,BufRead *.mm call s:FTmm() 1005 1006fun! s:FTmm() 1007 let n = 1 1008 while n < 10 1009 let line = getline(n) 1010 if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)' 1011 setf objcpp 1012 return 1013 endif 1014 let n = n + 1 1015 endwhile 1016 setf nroff 1017endfun 1018 1019" Not Quite C 1020au BufNewFile,BufRead *.nqc setf nqc 1021 1022" NSIS 1023au BufNewFile,BufRead *.nsi setf nsis 1024 1025" OCAML 1026au BufNewFile,BufRead *.ml,*.mli,*.mll,*.mly setf ocaml 1027 1028" Occam 1029au BufNewFile,BufRead *.occ setf occam 1030 1031" Omnimark 1032au BufNewFile,BufRead *.xom,*.xin setf omnimark 1033 1034" OpenROAD 1035au BufNewFile,BufRead *.or setf openroad 1036 1037" OPL 1038au BufNewFile,BufRead *.[Oo][Pp][Ll] setf opl 1039 1040" Oracle config file 1041au BufNewFile,BufRead *.ora setf ora 1042 1043" Packet filter conf 1044au BufNewFile,BufRead pf.conf setf pf 1045 1046" Pam conf 1047au BufNewFile,BufRead /etc/pam.conf setf pamconf 1048 1049" PApp 1050au BufNewFile,BufRead *.papp,*.pxml,*.pxsl setf papp 1051 1052" Password file 1053au BufNewFile,BufRead /etc/passwd,/etc/shadow,/etc/shadow- setf passwd 1054 1055" Pascal (also *.p) 1056au BufNewFile,BufRead *.pas setf pascal 1057 1058" Delphi project file 1059au BufNewFile,BufRead *.dpr setf pascal 1060 1061" Perl 1062if has("fname_case") 1063 au BufNewFile,BufRead *.pl,*.PL call s:FTpl() 1064else 1065 au BufNewFile,BufRead *.pl call s:FTpl() 1066endif 1067au BufNewFile,BufRead *.plx setf perl 1068 1069fun! s:FTpl() 1070 if exists("g:filetype_pl") 1071 exe "setf " . g:filetype_pl 1072 else 1073 " recognize Prolog by specific text in the first non-empty line 1074 " require a blank after the '%' because Perl uses "%list" and "%translate" 1075 let l = getline(nextnonblank(1)) 1076 if l =~ '\<prolog\>' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-' 1077 setf prolog 1078 else 1079 setf perl 1080 endif 1081 endif 1082endfun 1083 1084" Perl, XPM or XPM2 1085au BufNewFile,BufRead *.pm 1086 \ if getline(1) =~ "XPM2" | 1087 \ setf xpm2 | 1088 \ elseif getline(1) =~ "XPM" | 1089 \ setf xpm | 1090 \ else | 1091 \ setf perl | 1092 \ endif 1093 1094" Perl POD 1095au BufNewFile,BufRead *.pod setf pod 1096 1097" Php3 1098au BufNewFile,BufRead *.php,*.php3 setf php 1099 1100" Phtml 1101au BufNewFile,BufRead *.phtml setf phtml 1102 1103" Pike 1104au BufNewFile,BufRead *.pike,*.lpc,*.ulpc,*.pmod setf pike 1105 1106" Pinfo config 1107au BufNewFile,BufRead */etc/pinforc,*/.pinforc setf pinfo 1108 1109" Palm Resource compiler 1110au BufNewFile,BufRead *.rcp setf pilrc 1111 1112" Pine config 1113au BufNewFile,BufRead .pinerc,pinerc,.pinercex,pinercex setf pine 1114 1115" PL/M (also: *.inp) 1116au BufNewFile,BufRead *.plm,*.p36,*.pac setf plm 1117 1118" PL/SQL 1119au BufNewFile,BufRead *.pls,*.plsql setf plsql 1120 1121" PLP 1122au BufNewFile,BufRead *.plp setf plp 1123 1124" PO and PO template (GNU gettext) 1125au BufNewFile,BufRead *.po,*.pot setf po 1126 1127" Postfix main config 1128au BufNewFile,BufRead main.cf setf pfmain 1129 1130" PostScript (+ font files, encapsulated PostScript, Adobe Illustrator) 1131au BufNewFile,BufRead *.ps,*.pfa,*.afm,*.eps,*.epsf,*.epsi,*.ai setf postscr 1132 1133" PostScript Printer Description 1134au BufNewFile,BufRead *.ppd setf ppd 1135 1136" Povray 1137au BufNewFile,BufRead *.pov setf pov 1138 1139" Povray configuration 1140au BufNewFile,BufRead .povrayrc setf povini 1141 1142" Povray, PHP or assembly 1143au BufNewFile,BufRead *.inc call s:FTinc() 1144 1145fun! s:FTinc() 1146 if exists("g:filetype_inc") 1147 exe "setf " . g:filetype_inc 1148 else 1149 let lines = getline(1).getline(2).getline(3) 1150 if lines =~? "perlscript" 1151 setf aspperl 1152 elseif lines =~ "<%" 1153 setf aspvbs 1154 elseif lines =~ "<?" 1155 setf php 1156 else 1157 call s:FTasmsyntax() 1158 if exists("b:asmsyntax") 1159 exe "setf " . b:asmsyntax 1160 else 1161 setf pov 1162 endif 1163 endif 1164 endif 1165endfun 1166 1167" Printcap and Termcap 1168au BufNewFile,BufRead *printcap 1169 \ let b:ptcap_type = "print" | setf ptcap 1170au BufNewFile,BufRead *termcap 1171 \ let b:ptcap_type = "term" | setf ptcap 1172 1173" PCCTS / ANTRL 1174"au BufNewFile,BufRead *.g setf antrl 1175au BufNewFile,BufRead *.g setf pccts 1176 1177" PPWizard 1178au BufNewFile,BufRead *.it,*.ih setf ppwiz 1179 1180" Oracle Pro*C/C++ 1181au BufNewFile,BufRead .pc setf proc 1182 1183" Procmail 1184au BufNewFile,BufRead .procmail,.procmailrc setf procmail 1185 1186" Progress or CWEB 1187au BufNewFile,BufRead *.w call s:FTprogress_cweb() 1188 1189function! s:FTprogress_cweb() 1190 if exists("g:filetype_w") 1191 exe "setf " . g:filetype_w 1192 return 1193 endif 1194 if getline(1) =~ '&ANALYZE' || getline(3) =~ '&GLOBAL-DEFINE' 1195 setf progress 1196 else 1197 setf cweb 1198 endif 1199endfun 1200 1201" Progress or assembly 1202au BufNewFile,BufRead *.i call s:FTprogress_asm() 1203 1204function! s:FTprogress_asm() 1205 if exists("g:filetype_i") 1206 exe "setf " . g:filetype_i 1207 return 1208 endif 1209 " This function checks for an assembly comment the first ten lines. 1210 " If not found, assume Progress. 1211 let lnum = 1 1212 while lnum <= 10 && lnum < line('$') 1213 let line = getline(lnum) 1214 if line =~ '^\s*;' || line =~ '^\*' 1215 call s:FTasm() 1216 return 1217 elseif line !~ '^\s*$' || line =~ '^/\*' 1218 " Not an empty line: Doesn't look like valid assembly code. 1219 " Or it looks like a Progress /* comment 1220 break 1221 endif 1222 let lnum = lnum + 1 1223 endw 1224 setf progress 1225endfun 1226 1227" Progress or Pascal 1228au BufNewFile,BufRead *.p call s:FTprogress_pascal() 1229 1230function! s:FTprogress_pascal() 1231 if exists("g:filetype_p") 1232 exe "setf " . g:filetype_p 1233 return 1234 endif 1235 " This function checks for valid Pascal syntax in the first ten lines. 1236 " Look for either an opening comment or a program start. 1237 " If not found, assume Progress. 1238 let lnum = 1 1239 while lnum <= 10 && lnum < line('$') 1240 let line = getline(lnum) 1241 if line =~ '^\s*\(program\|unit\|procedure\|function\|const\|type\|var\)\>' 1242 \ || line =~ '^\s*{' || line =~ '^\s*(\*' 1243 setf pascal 1244 return 1245 elseif line !~ '^\s*$' || line =~ '^/\*' 1246 " Not an empty line: Doesn't look like valid Pascal code. 1247 " Or it looks like a Progress /* comment 1248 break 1249 endif 1250 let lnum = lnum + 1 1251 endw 1252 setf progress 1253endfun 1254 1255 1256" Software Distributor Product Specification File (POSIX 1387.2-1995) 1257au BufNewFile,BufRead *.psf setf psf 1258au BufNewFile,BufRead INDEX,INFO 1259 \ if getline(1) =~ '^\s*\(distribution\|installed_software\|root\|bundle\|product\)\s*$' | 1260 \ setf psf | 1261 \ endif 1262 1263" Prolog 1264au BufNewFile,BufRead *.pdb setf prolog 1265 1266" Protocols 1267au BufNewFile,BufRead /etc/protocols setf protocols 1268 1269" Pyrex 1270au BufNewFile,BufRead *.pyx,*.pxd setf pyrex 1271 1272" Python 1273au BufNewFile,BufRead *.py,*.pyw setf python 1274 1275" Radiance 1276au BufNewFile,BufRead *.rad,*.mat setf radiance 1277 1278" Ratpoison config/command files 1279au BufNewFile,BufRead .ratpoisonrc,ratpoisonrc setf ratpoison 1280 1281" RCS file 1282au BufNewFile,BufRead *\,v setf rcs 1283 1284" Readline 1285au BufNewFile,BufRead .inputrc,inputrc setf readline 1286 1287" Registry for MS-Windows 1288au BufNewFile,BufRead *.reg 1289 \ if getline(1) =~? '^REGEDIT[0-9]*\s*$\|^Windows Registry Editor Version \d*\.\d*\s*$' | setf registry | endif 1290 1291" Renderman Interface Bytestream 1292au BufNewFile,BufRead *.rib setf rib 1293 1294" Rexx 1295au BufNewFile,BufRead *.rexx,*.rex setf rexx 1296 1297" R (Splus) 1298au BufNewFile,BufRead *.s,*.S setf r 1299 1300" Rexx, Rebol or R 1301au BufNewFile,BufRead *.r,*.R call s:FTr() 1302 1303fun! s:FTr() 1304 if getline(1) =~ '^REBOL' 1305 setf rebol 1306 else 1307 let n = 1 1308 let max = line("$") 1309 if max > 50 1310 let max = 50 1311 endif 1312 while n < max 1313 " R has # comments 1314 if getline(n) =~ '^\s*#' 1315 setf r 1316 break 1317 endif 1318 " Rexx has /* comments */ 1319 if getline(n) =~ '^\s*/\*' 1320 setf rexx 1321 break 1322 endif 1323 let n = n + 1 1324 endwhile 1325 if n >= max 1326 setf rexx 1327 endif 1328 endif 1329endfun 1330 1331" Remind 1332au BufNewFile,BufRead .reminders* call s:StarSetf('remind') 1333 1334" Resolv.conf 1335au BufNewFile,BufRead resolv.conf setf resolv 1336 1337" Relax NG Compact 1338au BufNewFile,BufRead *.rnc setf rnc 1339 1340" RPL/2 1341au BufNewFile,BufRead *.rpl setf rpl 1342 1343" Robots.txt 1344au BufNewFile,BufRead robots.txt setf robots 1345 1346" Rpcgen 1347au BufNewFile,BufRead *.x setf rpcgen 1348 1349" reStructuredText Documentation Format 1350au BufNewFile,BufRead *.rst setf rst 1351 1352" RTF 1353au BufNewFile,BufRead *.rtf setf rtf 1354 1355" Ruby 1356au BufNewFile,BufRead *.rb,*.rbw,*.gem,*.gemspec setf ruby 1357 1358" Rantfile is like Ruby 1359au BufNewFile,BufRead [rR]antfile,*.rant setf ruby 1360 1361" S-lang (or shader language!) 1362au BufNewFile,BufRead *.sl setf slang 1363 1364" Samba config 1365au BufNewFile,BufRead smb.conf setf samba 1366 1367" SAS script 1368au BufNewFile,BufRead *.sas setf sas 1369 1370" Sather 1371au BufNewFile,BufRead *.sa setf sather 1372 1373" Scilab 1374au BufNewFile,BufRead *.sci setf scilab 1375 1376" SDL 1377au BufNewFile,BufRead *.sdl,*.pr setf sdl 1378 1379" sed 1380au BufNewFile,BufRead *.sed setf sed 1381 1382" Sieve (RFC 3028) 1383au BufNewFile,BufRead *.siv setf sieve 1384 1385" Sendmail 1386au BufNewFile,BufRead sendmail.cf setf sm 1387 1388" Sendmail .mc files are actually m4 1389au BufNewFile,BufRead *.mc setf m4 1390 1391" Services 1392au BufNewFile,BufRead /etc/services setf services 1393 1394" Service Location config 1395au BufNewFile,BufRead /etc/slp.conf setf slpconf 1396 1397" Service Location registration 1398au BufNewFile,BufRead /etc/slp.reg setf slpreg 1399 1400" Service Location SPI 1401au BufNewFile,BufRead /etc/slp.spi setf slpspi 1402 1403" Setserial config 1404au BufNewFile,BufRead /etc/serial.conf setf setserial 1405 1406" SGML 1407au BufNewFile,BufRead *.sgm,*.sgml 1408 \ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'linuxdoc' | 1409 \ setf sgmllnx | 1410 \ elseif getline(1) =~ '<!DOCTYPE.*DocBook' || getline(2) =~ '<!DOCTYPE.*DocBook' | 1411 \ let b:docbk_type="sgml" | 1412 \ setf docbk | 1413 \ else | 1414 \ setf sgml | 1415 \ endif 1416 1417" SGMLDECL 1418au BufNewFile,BufRead *.decl,*.dcl,*.dec 1419 \ if getline(1).getline(2).getline(3) =~? '^<!SGML' | 1420 \ setf sgmldecl | 1421 \ endif 1422 1423" SGML catalog file 1424au BufNewFile,BufRead catalog setf catalog 1425au BufNewFile,BufRead sgml.catalog* call s:StarSetf('catalog') 1426 1427" Shell scripts (sh, ksh, bash, bash2, csh); Allow .profile_foo etc. 1428" Gentoo ebuilds are actually bash scripts 1429au BufNewFile,BufRead .bashrc*,bashrc,bash.bashrc,.bash_profile*,.bash_logout*,*.bash,*.ebuild call SetFileTypeSH("bash") 1430au BufNewFile,BufRead .kshrc*,*.ksh call SetFileTypeSH("ksh") 1431au BufNewFile,BufRead /etc/profile,.profile*,*.sh,*.env call SetFileTypeSH(getline(1)) 1432 1433" Also called from scripts.vim. 1434fun! SetFileTypeSH(name) 1435 if expand("<amatch>") =~ g:ft_ignore_pat 1436 return 1437 endif 1438 if a:name =~ '\<ksh\>' 1439 let b:is_kornshell = 1 1440 if exists("b:is_bash") 1441 unlet b:is_bash 1442 endif 1443 if exists("b:is_sh") 1444 unlet b:is_sh 1445 endif 1446 elseif exists("g:bash_is_sh") || a:name =~ '\<bash\>' || a:name =~ '\<bash2\>' 1447 let b:is_bash = 1 1448 if exists("b:is_kornshell") 1449 unlet b:is_kornshell 1450 endif 1451 if exists("b:is_sh") 1452 unlet b:is_sh 1453 endif 1454 elseif a:name =~ '\<sh\>' 1455 let b:is_sh = 1 1456 if exists("b:is_kornshell") 1457 unlet b:is_kornshell 1458 endif 1459 if exists("b:is_bash") 1460 unlet b:is_bash 1461 endif 1462 endif 1463 call SetFileTypeShell("sh") 1464endfun 1465 1466" For shell-like file types, check for an "exec" command hidden in a comment, 1467" as used for Tcl. 1468" Also called from scripts.vim, thus can't be local to this script. 1469fun! SetFileTypeShell(name) 1470 if expand("<amatch>") =~ g:ft_ignore_pat 1471 return 1472 endif 1473 let l = 2 1474 while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)' 1475 " Skip empty and comment lines. 1476 let l = l + 1 1477 endwhile 1478 if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$' 1479 " Found an "exec" line after a comment with continuation 1480 let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '') 1481 if n =~ '\<tclsh\|\<wish' 1482 setf tcl 1483 return 1484 endif 1485 endif 1486 exe "setf " . a:name 1487endfun 1488 1489" tcsh scripts 1490au BufNewFile,BufRead .tcshrc*,*.tcsh,tcsh.tcshrc,tcsh.login call SetFileTypeShell("tcsh") 1491 1492" csh scripts, but might also be tcsh scripts (on some systems csh is tcsh) 1493au BufNewFile,BufRead .login*,.cshrc*,csh.cshrc,csh.login,csh.logout,*.csh,.alias call s:CSH() 1494 1495fun! s:CSH() 1496 if exists("g:filetype_csh") 1497 call SetFileTypeShell(g:filetype_csh) 1498 elseif &shell =~ "tcsh" 1499 call SetFileTypeShell("tcsh") 1500 else 1501 call SetFileTypeShell("csh") 1502 endif 1503endfun 1504 1505" Z-Shell script 1506au BufNewFile,BufRead .zprofile,/etc/zprofile,.zfbfmarks setf zsh 1507au BufNewFile,BufRead .zsh*,.zlog*,.zcompdump* call s:StarSetf('zsh') 1508 1509" Scheme 1510au BufNewFile,BufRead *.scm,*.ss setf scheme 1511 1512" Screen RC 1513au BufNewFile,BufRead .screenrc,screenrc setf screen 1514 1515" Simula 1516au BufNewFile,BufRead *.sim setf simula 1517 1518" SINDA 1519au BufNewFile,BufRead *.sin,*.s85 setf sinda 1520 1521" SKILL 1522au BufNewFile,BufRead *.il,*.ils,*.cdf setf skill 1523 1524" SLRN 1525au BufNewFile,BufRead .slrnrc setf slrnrc 1526au BufNewFile,BufRead *.score setf slrnsc 1527 1528" Smalltalk (and TeX) 1529au BufNewFile,BufRead *.st setf st 1530au BufNewFile,BufRead *.cls 1531 \ if getline(1) =~ '^%' | 1532 \ setf tex | 1533 \ else | 1534 \ setf st | 1535 \ endif 1536 1537" Smarty templates 1538au BufNewFile,BufRead *.tpl setf smarty 1539 1540" SMIL or XML 1541au BufNewFile,BufRead *.smil 1542 \ if getline(1) =~ '<?\s*xml.*?>' | 1543 \ setf xml | 1544 \ else | 1545 \ setf smil | 1546 \ endif 1547 1548" SMIL or SNMP MIB file 1549au BufNewFile,BufRead *.smi 1550 \ if getline(1) =~ '\<smil\>' | 1551 \ setf smil | 1552 \ else | 1553 \ setf mib | 1554 \ endif 1555 1556" SMITH 1557au BufNewFile,BufRead *.smt,*.smith setf smith 1558 1559" Snobol4 1560au BufNewFile,BufRead *.sno setf snobol4 1561 1562" SNMP MIB files 1563au BufNewFile,BufRead *.mib,*.my setf mib 1564 1565" Snort Configuration 1566au BufNewFile,BufRead *.hog,snort.conf,vision.conf,*.rules setf hog 1567 1568" Spec (Linux RPM) 1569au BufNewFile,BufRead *.spec setf spec 1570 1571" Speedup (AspenTech plant simulator) 1572au BufNewFile,BufRead *.speedup,*.spdata,*.spd setf spup 1573 1574" Slice 1575au BufNewFile,BufRead *.ice setf slice 1576 1577" Spice 1578au BufNewFile,BufRead *.sp,*.spice setf spice 1579 1580" Spyce 1581au BufNewFile,BufRead *.spy,*.spi setf spyce 1582 1583" Squid 1584au BufNewFile,BufRead squid.conf setf squid 1585 1586" SQL for Oracle Designer 1587au BufNewFile,BufRead *.tyb,*.typ,*.tyc,*.pkb,*.pks setf sql 1588 1589" SQL 1590au BufNewFile,BufRead *.sql call s:SQL() 1591 1592fun! s:SQL() 1593 if exists("g:filetype_sql") 1594 exe "setf " . g:filetype_sql 1595 else 1596 setf sql 1597 endif 1598endfun 1599 1600" SQLJ 1601au BufNewFile,BufRead *.sqlj setf sqlj 1602 1603" SQR 1604au BufNewFile,BufRead *.sqr,*.sqi setf sqr 1605 1606" OpenSSH configuration 1607au BufNewFile,BufRead ssh_config,*/.ssh/config setf sshconfig 1608 1609" OpenSSH server configuration 1610au BufNewFile,BufRead sshd_config setf sshdconfig 1611 1612" Stored Procedures 1613au BufNewFile,BufRead *.stp setf stp 1614 1615" Standard ML 1616au BufNewFile,BufRead *.sml setf sml 1617 1618" Sysctl 1619au BufNewFile,BufRead /etc/sysctl.conf setf sysctl 1620 1621" Sudoers 1622au BufNewFile,BufRead /etc/sudoers,sudoers.tmp setf sudoers 1623 1624" If the first line starts with '#' and contains 'perl' it's probably a Perl 1625" file. 1626fun! s:FTperl() 1627 if getline(1)[0] == '#' && getline(1) =~ 'perl' 1628 setf perl 1629 return 1 1630 endif 1631 return 0 1632endfun 1633 1634" Tads (or Nroff or Perl test file) 1635au BufNewFile,BufRead *.t 1636 \ if !s:FTnroff() && !s:FTperl() | setf tads | endif 1637 1638" Tags 1639au BufNewFile,BufRead tags setf tags 1640 1641" TAK 1642au BufNewFile,BufRead *.tak setf tak 1643 1644" Tcl (JACL too) 1645au BufNewFile,BufRead *.tcl,*.tk,*.itcl,*.itk,*.jacl setf tcl 1646 1647" TealInfo 1648au BufNewFile,BufRead *.tli setf tli 1649 1650" Telix Salt 1651au BufNewFile,BufRead *.slt setf tsalt 1652 1653" Terminfo 1654au BufNewFile,BufRead *.ti setf terminfo 1655 1656" TeX 1657au BufNewFile,BufRead *.latex,*.sty,*.dtx,*.ltx,*.bbl setf tex 1658au BufNewFile,BufRead *.tex call s:FTtex() 1659 1660fun! s:FTtex() 1661 let n = 1 1662 while n < 10 && n < line("$") 1663 let line = getline(n) 1664 if line =~ '^\s*\\\%(documentclass\>\|usepackage\>\|begin{\)' 1665 setf tex 1666 return 1667 elseif line =~ '^\s*\\\%(start\l\+\|setup\l\+\|usemodule\)\>' 1668 setf context 1669 return 1670 endif 1671 let n = n + 1 1672 endwhile 1673 setf tex 1674endfun 1675 1676" Context 1677au BufNewFile,BufRead tex/context/*/*.tex setf context 1678 1679" Texinfo 1680au BufNewFile,BufRead *.texinfo,*.texi,*.txi setf texinfo 1681 1682" TeX configuration 1683au BufNewFile,BufRead texmf.cnf setf texmf 1684 1685" Tidy config 1686au BufNewFile,BufRead .tidyrc,tidyrc setf tidy 1687 1688" TF mud client 1689au BufNewFile,BufRead *.tf,.tfrc,tfrc setf tf 1690 1691" TPP - Text Presentation Program 1692au BufNewFile,BufReadPost *.tpp setf tpp 1693 1694" Trustees 1695au BufNewFile,BufRead trustees.conf setf trustees 1696 1697" TSS - Geometry 1698au BufNewFile,BufReadPost *.tssgm setf tssgm 1699 1700" TSS - Optics 1701au BufNewFile,BufReadPost *.tssop setf tssop 1702 1703" TSS - Command Line (temporary) 1704au BufNewFile,BufReadPost *.tsscl setf tsscl 1705 1706" Motif UIT/UIL files 1707au BufNewFile,BufRead *.uit,*.uil setf uil 1708 1709" Udev conf 1710au BufNewFile,BufRead /etc/udev/udev.conf setf udevconf 1711 1712" Udev rules 1713au BufNewFile,BufRead /etc/udev/rules.d/*.rules setf udevrules 1714 1715" Udev permissions 1716au BufNewFile,BufRead /etc/udev/permissions.d/*.permissions setf udevperm 1717" 1718" Udev symlinks config 1719au BufNewFile,BufRead /etc/udev/cdsymlinks.conf setf sh 1720 1721" UnrealScript 1722au BufNewFile,BufRead *.uc setf uc 1723 1724" Updatedb 1725au BufNewFile,BufRead /etc/updatedb.conf setf updatedb 1726 1727" Verilog HDL 1728au BufNewFile,BufRead *.v setf verilog 1729 1730" Verilog-AMS HDL 1731au BufNewFile,BufRead *.va,*.vams setf verilogams 1732 1733" VHDL 1734au BufNewFile,BufRead *.hdl,*.vhd,*.vhdl,*.vbe,*.vst setf vhdl 1735au BufNewFile,BufRead *.vhdl_[0-9]* call s:StarSetf('vhdl') 1736 1737" Vim script 1738au BufNewFile,BufRead *.vim,.exrc,_exrc setf vim 1739 1740" Viminfo file 1741au BufNewFile,BufRead .viminfo,_viminfo setf viminfo 1742 1743" Virata Config Script File 1744au BufRead,BufNewFile *.hw,*.module,*.pkg setf virata 1745 1746" Visual Basic (also uses *.bas) or FORM 1747au BufNewFile,BufRead *.frm call s:FTVB("form") 1748 1749" SaxBasic is close to Visual Basic 1750au BufNewFile,BufRead *.sba setf vb 1751 1752" Vgrindefs file 1753au BufNewFile,BufRead vgrindefs setf vgrindefs 1754 1755" VRML V1.0c 1756au BufNewFile,BufRead *.wrl setf vrml 1757 1758" Webmacro 1759au BufNewFile,BufRead *.wm setf webmacro 1760 1761" Wget config 1762au BufNewFile,BufRead .wgetrc,wgetrc setf wget 1763 1764" Website MetaLanguage 1765au BufNewFile,BufRead *.wml setf wml 1766 1767" Winbatch 1768au BufNewFile,BufRead *.wbt setf winbatch 1769 1770" WvDial 1771au BufNewFile,BufRead wvdial.conf,.wvdialrc setf wvdial 1772 1773" CVS RC file 1774au BufNewFile,BufRead .cvsrc setf cvsrc 1775 1776" CVS commit file 1777au BufNewFile,BufRead cvs\d\+ setf cvs 1778 1779" WEB (*.web is also used for Winbatch: Guess, based on expecting "%" comment 1780" lines in a WEB file). 1781au BufNewFile,BufRead *.web 1782 \ if getline(1)[0].getline(2)[0].getline(3)[0].getline(4)[0].getline(5)[0] =~ "%" | 1783 \ setf web | 1784 \ else | 1785 \ setf winbatch | 1786 \ endif 1787 1788" Windows Scripting Host and Windows Script Component 1789au BufNewFile,BufRead *.ws[fc] setf wsh 1790 1791" X Pixmap (dynamically sets colors, use BufEnter to make it work better) 1792au BufEnter *.xpm 1793 \ if getline(1) =~ "XPM2" | 1794 \ setf xpm2 | 1795 \ else | 1796 \ setf xpm | 1797 \ endif 1798au BufEnter *.xpm2 setf xpm2 1799 1800" XFree86 config 1801au BufNewFile,BufRead XF86Config 1802 \ if getline(1) =~ '\<XConfigurator\>' | 1803 \ let b:xf86c_xfree86_version = 3 | 1804 \ endif | 1805 \ setf xf86conf 1806 1807" Xorg config 1808au BufNewFile,BufRead xorg.conf,xorg.conf-4 let b:xf86c_xfree86_version = 4 | setf xf86conf 1809 1810" Xinetd conf 1811au BufNewFile,BufRead /etc/xinetd.conf setf xinetd 1812 1813" XS Perl extension interface language 1814au BufNewFile,BufRead *.xs setf xs 1815 1816" X resources file 1817au BufNewFile,BufRead .Xdefaults,.Xpdefaults,.Xresources,xdm-config,*.ad setf xdefaults 1818 1819" Xmath 1820au BufNewFile,BufRead *.msc,*.msf setf xmath 1821au BufNewFile,BufRead *.ms 1822 \ if !s:FTnroff() | setf xmath | endif 1823 1824" XML 1825au BufNewFile,BufRead *.xml 1826 \ if getline(1) . getline(2) . getline(3) =~ '<!DOCTYPE.*DocBook' | 1827 \ let b:docbk_type="xml" | 1828 \ setf docbk | 1829 \ else | 1830 \ setf xml | 1831 \ endif 1832 1833" XMI (holding UML models) is also XML 1834au BufNewFile,BufRead *.xmi setf xml 1835 1836" CSPROJ files are Visual Studio.NET's XML-based project config files 1837au BufNewFile,BufRead *.csproj,*.csproj.user setf xml 1838 1839" Qt Linguist translation source and Qt User Interface Files are XML 1840au BufNewFile,BufRead *.ts,*.ui setf xml 1841 1842" Xdg menus 1843au BufNewFile,BufRead /etc/xdg/menus/*.menu setf xml 1844 1845" Xquery 1846au BufNewFile,BufRead *.xq,*.xql,*.xqm,*.xquery,*.xqy setf xquery 1847 1848" XSD 1849au BufNewFile,BufRead *.xsd setf xsd 1850 1851" Xslt 1852au BufNewFile,BufRead *.xsl,*.xslt setf xslt 1853 1854" Yacc 1855au BufNewFile,BufRead *.yy setf yacc 1856 1857" Yacc or racc 1858au BufNewFile,BufRead *.y call s:FTy() 1859 1860fun! s:FTy() 1861 let n = 1 1862 while n < 100 && n < line("$") 1863 let line = getline(n) 1864 if line =~ '^\s*%' 1865 setf yacc 1866 return 1867 endif 1868 if getline(n) =~ '^\s*\(#\|class\>\)' && getline(n) !~ '^\s*#\s*include' 1869 setf racc 1870 return 1871 endif 1872 let n = n + 1 1873 endwhile 1874 setf yacc 1875endfun 1876 1877 1878" Yaml 1879au BufNewFile,BufRead *.yaml,*.yml setf yaml 1880 1881" Z80 assembler asz80 1882au BufNewFile,BufRead *.z8a setf z8a 1883 1884augroup END 1885 1886 1887" Source the user-specified filetype file, for backwards compatibility with 1888" Vim 5.x. 1889if exists("myfiletypefile") && filereadable(expand(myfiletypefile)) 1890 execute "source " . myfiletypefile 1891endif 1892 1893 1894" Check for "*" after loading myfiletypefile, so that scripts.vim is only used 1895" when there are no matching file name extensions. 1896" Don't do this for compressed files. 1897augroup filetypedetect 1898au BufNewFile,BufRead * 1899 \ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat 1900 \ | runtime! scripts.vim | endif 1901au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif 1902 1903 1904" Extra checks for when no filetype has been detected now. Mostly used for 1905" patterns that end in "*". E.g., "zsh*" matches "zsh.vim", but that's a Vim 1906" script file. 1907" Most of these should call s:StarSetf() to avoid names ending in .gz and the 1908" like are used. 1909 1910" Asterisk config file 1911au BufNewFile,BufRead *asterisk/*.conf* call s:StarSetf('asterisk') 1912 1913" BIND zone 1914au BufNewFile,BufRead /var/named/* call s:StarSetf('bindzone') 1915 1916" Changelog 1917au BufNewFile,BufRead [cC]hange[lL]og* 1918 \ if getline(1) =~ '; urgency=' 1919 \| call s:StarSetf('debchangelog') 1920 \|else 1921 \| call s:StarSetf('changelog') 1922 \|endif 1923 1924" Crontab 1925au BufNewFile,BufRead crontab,crontab.* call s:StarSetf('crontab') 1926 1927" Dracula 1928au BufNewFile,BufRead drac.* call s:StarSetf('dracula') 1929 1930" Fvwm 1931au BufNewFile,BufRead *fvwmrc*,*fvwm95*.hook 1932 \ let b:fvwm_version = 1 | call s:StarSetf('fvwm') 1933au BufNewFile,BufRead *fvwm2rc* 1934 \ if expand("<afile>:e") == "m4" 1935 \| call s:StarSetf('fvwm2m4') 1936 \|else 1937 \| let b:fvwm_version = 2 | call s:StarSetf('fvwm') 1938 \|endif 1939 1940" GTK RC 1941au BufNewFile,BufRead .gtkrc*,gtkrc* call s:StarSetf('gtkrc') 1942 1943" Jam 1944au BufNewFile,BufRead Prl*.*,JAM*.* call s:StarSetf('jam') 1945 1946" Jargon 1947au! BufNewFile,BufRead *jarg* 1948 \ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'THIS IS THE JARGON FILE' 1949 \| call s:StarSetf('jargon') 1950 \|endif 1951 1952" Makefile 1953au BufNewFile,BufRead [mM]akefile* call s:StarSetf('make') 1954 1955" Modconf 1956au BufNewFile,BufRead /etc/modprobe.* call s:StarSetf('modconf') 1957 1958" Ruby Makefile 1959au BufNewFile,BufRead [rR]akefile* call s:StarSetf('ruby') 1960 1961" Mutt setup file 1962au BufNewFile,BufRead mutt{ng,}rc*,Mutt{ng,}rc* call s:StarSetf('muttrc') 1963 1964" Nroff macros 1965au BufNewFile,BufRead tmac.* call s:StarSetf('nroff') 1966 1967" Pam conf 1968au BufNewFile,BufRead /etc/pam.d/* call s:StarSetf('pamconf') 1969 1970" Printcap and Termcap 1971au BufNewFile,BufRead *printcap* 1972 \ if !did_filetype() 1973 \| let b:ptcap_type = "print" | call s:StarSetf('ptcap') 1974 \|endif 1975au BufNewFile,BufRead *termcap* 1976 \ if !did_filetype() 1977 \| let b:ptcap_type = "term" | call s:StarSetf('ptcap') 1978 \|endif 1979 1980" Vim script 1981au BufNewFile,BufRead *vimrc* call s:StarSetf('vim') 1982 1983" Subversion commit file 1984au BufNewFile,BufRead svn-commit*.tmp setf svn 1985 1986" X resources file 1987au BufNewFile,BufRead Xresources*,*/app-defaults/*,*/Xresources/* call s:StarSetf('xdefaults') 1988 1989" XFree86 config 1990au BufNewFile,BufRead XF86Config-4* 1991 \ let b:xf86c_xfree86_version = 4 | call s:StarSetf('xf86conf') 1992au BufNewFile,BufRead XF86Config* 1993 \ if getline(1) =~ '\<XConfigurator\>' 1994 \| let b:xf86c_xfree86_version = 3 1995 \|endif 1996 \|call s:StarSetf('xf86conf') 1997 1998" X11 xmodmap 1999au BufNewFile,BufRead *xmodmap* call s:StarSetf('xmodmap') 2000 2001" Xinetd conf 2002au BufNewFile,BufRead /etc/xinetd.d/* call s:StarSetf('xinetd') 2003 2004" Z-Shell script 2005au BufNewFile,BufRead zsh*,zlog* call s:StarSetf('zsh') 2006 2007 2008" Generic configuration file (check this last, it's just guessing!) 2009au BufNewFile,BufRead,StdinReadPost * 2010 \ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat 2011 \ && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#' 2012 \ || getline(4) =~ '^#' || getline(5) =~ '^#') | 2013 \ setf conf | 2014 \ endif 2015 2016" Use the plugin-filetype checks last, they may overrule any of the previously 2017" detected filetypes. 2018runtime! ftdetect/*.vim 2019 2020augroup END 2021 2022 2023" If the GUI is already running, may still need to install the Syntax menu. 2024" Don't do it when the 'M' flag is included in 'guioptions'. 2025if has("menu") && has("gui_running") 2026 \ && !exists("did_install_syntax_menu") && &guioptions !~# "M" 2027 source <sfile>:p:h/menu.vim 2028endif 2029 2030" Restore 'cpoptions' 2031let &cpo = s:cpo_save 2032unlet s:cpo_save 2033