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