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