1" Vim support file to detect file types 2" 3" Maintainer: Bram Moolenaar <[email protected]> 4" Last Change: 2017 Mar 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 19if exists("*fnameescape") 20au BufNewFile,BufRead ?\+.orig,?\+.bak,?\+.old,?\+.new,?\+.dpkg-dist,?\+.dpkg-old,?\+.dpkg-new,?\+.dpkg-bak,?\+.rpmsave,?\+.rpmnew,?\+.pacsave,?\+.pacnew 21 \ exe "doau filetypedetect BufRead " . fnameescape(expand("<afile>:r")) 22au BufNewFile,BufRead *~ 23 \ let s:name = expand("<afile>") | 24 \ let s:short = substitute(s:name, '\~$', '', '') | 25 \ if s:name != s:short && s:short != "" | 26 \ exe "doau filetypedetect BufRead " . fnameescape(s:short) | 27 \ endif | 28 \ unlet! s:name s:short 29au BufNewFile,BufRead ?\+.in 30 \ if expand("<afile>:t") != "configure.in" | 31 \ exe "doau filetypedetect BufRead " . fnameescape(expand("<afile>:r")) | 32 \ endif 33elseif &verbose > 0 34 echomsg "Warning: some filetypes will not be recognized because this version of Vim does not have fnameescape()" 35endif 36 37" Pattern used to match file names which should not be inspected. 38" Currently finds compressed files. 39if !exists("g:ft_ignore_pat") 40 let g:ft_ignore_pat = '\.\(Z\|gz\|bz2\|zip\|tgz\)$' 41endif 42 43" Function used for patterns that end in a star: don't set the filetype if the 44" file name matches ft_ignore_pat. 45func! s:StarSetf(ft) 46 if expand("<amatch>") !~ g:ft_ignore_pat 47 exe 'setf ' . a:ft 48 endif 49endfunc 50 51" Abaqus or Trasys 52au BufNewFile,BufRead *.inp call s:Check_inp() 53 54func! s:Check_inp() 55 if getline(1) =~ '^\*' 56 setf abaqus 57 else 58 let n = 1 59 if line("$") > 500 60 let nmax = 500 61 else 62 let nmax = line("$") 63 endif 64 while n <= nmax 65 if getline(n) =~? "^header surface data" 66 setf trasys 67 break 68 endif 69 let n = n + 1 70 endwhile 71 endif 72endfunc 73 74" A-A-P recipe 75au BufNewFile,BufRead *.aap setf aap 76 77" A2ps printing utility 78au BufNewFile,BufRead */etc/a2ps.cfg,*/etc/a2ps/*.cfg,a2psrc,.a2psrc setf a2ps 79 80" ABAB/4 81au BufNewFile,BufRead *.abap setf abap 82 83" ABC music notation 84au BufNewFile,BufRead *.abc setf abc 85 86" ABEL 87au BufNewFile,BufRead *.abl setf abel 88 89" AceDB 90au BufNewFile,BufRead *.wrm setf acedb 91 92" Ada (83, 9X, 95) 93au BufNewFile,BufRead *.adb,*.ads,*.ada setf ada 94if has("vms") 95 au BufNewFile,BufRead *.gpr,*.ada_m,*.adc setf ada 96else 97 au BufNewFile,BufRead *.gpr setf ada 98endif 99 100" AHDL 101au BufNewFile,BufRead *.tdf setf ahdl 102 103" AMPL 104au BufNewFile,BufRead *.run setf ampl 105 106" Ant 107au BufNewFile,BufRead build.xml setf ant 108 109" Arduino 110au BufNewFile,BufRead *.ino,*.pde setf arduino 111 112" Apache style config file 113au BufNewFile,BufRead proftpd.conf* call s:StarSetf('apachestyle') 114 115" Apache config file 116au BufNewFile,BufRead .htaccess,*/etc/httpd/*.conf setf apache 117 118" XA65 MOS6510 cross assembler 119au BufNewFile,BufRead *.a65 setf a65 120 121" Applescript 122au BufNewFile,BufRead *.scpt setf applescript 123 124" Applix ELF 125au BufNewFile,BufRead *.am 126 \ if expand("<afile>") !~? 'Makefile.am\>' | setf elf | endif 127 128" ALSA configuration 129au BufNewFile,BufRead .asoundrc,*/usr/share/alsa/alsa.conf,*/etc/asound.conf setf alsaconf 130 131" Arc Macro Language 132au BufNewFile,BufRead *.aml setf aml 133 134" APT config file 135au BufNewFile,BufRead apt.conf setf aptconf 136au BufNewFile,BufRead */.aptitude/config setf aptconf 137au BufNewFile,BufRead */etc/apt/apt.conf.d/{[-_[:alnum:]]\+,[-_.[:alnum:]]\+.conf} setf aptconf 138 139" Arch Inventory file 140au BufNewFile,BufRead .arch-inventory,=tagging-method setf arch 141 142" ART*Enterprise (formerly ART-IM) 143au BufNewFile,BufRead *.art setf art 144 145" AsciiDoc 146au BufNewFile,BufRead *.asciidoc,*.adoc setf asciidoc 147 148" ASN.1 149au BufNewFile,BufRead *.asn,*.asn1 setf asn 150 151" Active Server Pages (with Visual Basic Script) 152au BufNewFile,BufRead *.asa 153 \ if exists("g:filetype_asa") | 154 \ exe "setf " . g:filetype_asa | 155 \ else | 156 \ setf aspvbs | 157 \ endif 158 159" Active Server Pages (with Perl or Visual Basic Script) 160au BufNewFile,BufRead *.asp 161 \ if exists("g:filetype_asp") | 162 \ exe "setf " . g:filetype_asp | 163 \ elseif getline(1) . getline(2) . getline(3) =~? "perlscript" | 164 \ setf aspperl | 165 \ else | 166 \ setf aspvbs | 167 \ endif 168 169" Grub (must be before catch *.lst) 170au BufNewFile,BufRead */boot/grub/menu.lst,*/boot/grub/grub.conf,*/etc/grub.conf setf grub 171 172" Assembly (all kinds) 173" *.lst is not pure assembly, it has two extra columns (address, byte codes) 174au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst call s:FTasm() 175 176" This function checks for the kind of assembly that is wanted by the user, or 177" can be detected from the first five lines of the file. 178func! s:FTasm() 179 " make sure b:asmsyntax exists 180 if !exists("b:asmsyntax") 181 let b:asmsyntax = "" 182 endif 183 184 if b:asmsyntax == "" 185 call s:FTasmsyntax() 186 endif 187 188 " if b:asmsyntax still isn't set, default to asmsyntax or GNU 189 if b:asmsyntax == "" 190 if exists("g:asmsyntax") 191 let b:asmsyntax = g:asmsyntax 192 else 193 let b:asmsyntax = "asm" 194 endif 195 endif 196 197 exe "setf " . fnameescape(b:asmsyntax) 198endfunc 199 200func! s:FTasmsyntax() 201 " see if file contains any asmsyntax=foo overrides. If so, change 202 " b:asmsyntax appropriately 203 let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4). 204 \" ".getline(5)." " 205 let match = matchstr(head, '\sasmsyntax=\zs[a-zA-Z0-9]\+\ze\s') 206 if match != '' 207 let b:asmsyntax = match 208 elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library')) 209 let b:asmsyntax = "vmasm" 210 endif 211endfunc 212 213" Macro (VAX) 214au BufNewFile,BufRead *.mar setf vmasm 215 216" Atlas 217au BufNewFile,BufRead *.atl,*.as setf atlas 218 219" Autoit v3 220au BufNewFile,BufRead *.au3 setf autoit 221 222" Autohotkey 223au BufNewFile,BufRead *.ahk setf autohotkey 224 225" Automake 226au BufNewFile,BufRead [mM]akefile.am,GNUmakefile.am setf automake 227 228" Autotest .at files are actually m4 229au BufNewFile,BufRead *.at setf m4 230 231" Avenue 232au BufNewFile,BufRead *.ave setf ave 233 234" Awk 235au BufNewFile,BufRead *.awk setf awk 236 237" B 238au BufNewFile,BufRead *.mch,*.ref,*.imp setf b 239 240" BASIC or Visual Basic 241au BufNewFile,BufRead *.bas call s:FTVB("basic") 242 243" Check if one of the first five lines contains "VB_Name". In that case it is 244" probably a Visual Basic file. Otherwise it's assumed to be "alt" filetype. 245func! s:FTVB(alt) 246 if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)' 247 setf vb 248 else 249 exe "setf " . a:alt 250 endif 251endfunc 252 253" Visual Basic Script (close to Visual Basic) or Visual Basic .NET 254au BufNewFile,BufRead *.vb,*.vbs,*.dsm,*.ctl setf vb 255 256" IBasic file (similar to QBasic) 257au BufNewFile,BufRead *.iba,*.ibi setf ibasic 258 259" FreeBasic file (similar to QBasic) 260au BufNewFile,BufRead *.fb,*.bi setf freebasic 261 262" Batch file for MSDOS. 263au BufNewFile,BufRead *.bat,*.sys setf dosbatch 264" *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd. 265au BufNewFile,BufRead *.cmd 266 \ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif 267 268" Batch file for 4DOS 269au BufNewFile,BufRead *.btm call s:FTbtm() 270func! s:FTbtm() 271 if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm 272 setf dosbatch 273 else 274 setf btm 275 endif 276endfunc 277 278" BC calculator 279au BufNewFile,BufRead *.bc setf bc 280 281" BDF font 282au BufNewFile,BufRead *.bdf setf bdf 283 284" BibTeX bibliography database file 285au BufNewFile,BufRead *.bib setf bib 286 287" BibTeX Bibliography Style 288au BufNewFile,BufRead *.bst setf bst 289 290" BIND configuration 291au BufNewFile,BufRead named.conf,rndc.conf setf named 292 293" BIND zone 294au BufNewFile,BufRead named.root setf bindzone 295au BufNewFile,BufRead *.db call s:BindzoneCheck('') 296 297func! s:BindzoneCheck(default) 298 if getline(1).getline(2).getline(3).getline(4) =~ '^; <<>> DiG [0-9.]\+ <<>>\|BIND.*named\|$ORIGIN\|$TTL\|IN\s\+SOA' 299 setf bindzone 300 elseif a:default != '' 301 exe 'setf ' . a:default 302 endif 303endfunc 304 305" Blank 306au BufNewFile,BufRead *.bl setf blank 307 308" Blkid cache file 309au BufNewFile,BufRead */etc/blkid.tab,*/etc/blkid.tab.old setf xml 310 311" Bazel (http://bazel.io) 312autocmd BufRead,BufNewFile *.bzl,WORKSPACE setfiletype bzl 313if has("fname_case") 314 autocmd BufRead,BufNewFile BUILD setfiletype bzl 315endif 316 317" C or lpc 318au BufNewFile,BufRead *.c call s:FTlpc() 319 320func! s:FTlpc() 321 if exists("g:lpc_syntax_for_c") 322 let lnum = 1 323 while lnum <= 12 324 if getline(lnum) =~# '^\(//\|inherit\|private\|protected\|nosave\|string\|object\|mapping\|mixed\)' 325 setf lpc 326 return 327 endif 328 let lnum = lnum + 1 329 endwhile 330 endif 331 setf c 332endfunc 333 334" Calendar 335au BufNewFile,BufRead calendar setf calendar 336 337" C# 338au BufNewFile,BufRead *.cs setf cs 339 340" CSDL 341au BufNewFile,BufRead *.csdl setf csdl 342 343" Cabal 344au BufNewFile,BufRead *.cabal setf cabal 345 346" Cdrdao TOC 347au BufNewFile,BufRead *.toc setf cdrtoc 348 349" Cdrdao config 350au BufNewFile,BufRead */etc/cdrdao.conf,*/etc/defaults/cdrdao,*/etc/default/cdrdao,.cdrdao setf cdrdaoconf 351 352" Cfengine 353au BufNewFile,BufRead cfengine.conf setf cfengine 354 355" ChaiScript 356au BufRead,BufNewFile *.chai setf chaiscript 357 358" Comshare Dimension Definition Language 359au BufNewFile,BufRead *.cdl setf cdl 360 361" Conary Recipe 362au BufNewFile,BufRead *.recipe setf conaryrecipe 363 364" Controllable Regex Mutilator 365au BufNewFile,BufRead *.crm setf crm 366 367" Cyn++ 368au BufNewFile,BufRead *.cyn setf cynpp 369 370" Cynlib 371" .cc and .cpp files can be C++ or Cynlib. 372au BufNewFile,BufRead *.cc 373 \ if exists("cynlib_syntax_for_cc")|setf cynlib|else|setf cpp|endif 374au BufNewFile,BufRead *.cpp 375 \ if exists("cynlib_syntax_for_cpp")|setf cynlib|else|setf cpp|endif 376 377" C++ 378au BufNewFile,BufRead *.cxx,*.c++,*.hh,*.hxx,*.hpp,*.ipp,*.moc,*.tcc,*.inl setf cpp 379if has("fname_case") 380 au BufNewFile,BufRead *.C,*.H setf cpp 381endif 382 383" .h files can be C, Ch C++, ObjC or ObjC++. 384" Set c_syntax_for_h if you want C, ch_syntax_for_h if you want Ch. ObjC is 385" detected automatically. 386au BufNewFile,BufRead *.h call s:FTheader() 387 388func! s:FTheader() 389 if match(getline(1, min([line("$"), 200])), '^@\(interface\|end\|class\)') > -1 390 if exists("g:c_syntax_for_h") 391 setf objc 392 else 393 setf objcpp 394 endif 395 elseif exists("g:c_syntax_for_h") 396 setf c 397 elseif exists("g:ch_syntax_for_h") 398 setf ch 399 else 400 setf cpp 401 endif 402endfunc 403 404" Ch (CHscript) 405au BufNewFile,BufRead *.chf setf ch 406 407" TLH files are C++ headers generated by Visual C++'s #import from typelibs 408au BufNewFile,BufRead *.tlh setf cpp 409 410" Cascading Style Sheets 411au BufNewFile,BufRead *.css setf css 412 413" Century Term Command Scripts (*.cmd too) 414au BufNewFile,BufRead *.con setf cterm 415 416" Changelog 417au BufNewFile,BufRead changelog.Debian,changelog.dch,NEWS.Debian,NEWS.dch 418 \ setf debchangelog 419 420au BufNewFile,BufRead [cC]hange[lL]og 421 \ if getline(1) =~ '; urgency=' 422 \| setf debchangelog 423 \| else 424 \| setf changelog 425 \| endif 426 427au BufNewFile,BufRead NEWS 428 \ if getline(1) =~ '; urgency=' 429 \| setf debchangelog 430 \| endif 431 432" CHILL 433au BufNewFile,BufRead *..ch setf chill 434 435" Changes for WEB and CWEB or CHILL 436au BufNewFile,BufRead *.ch call s:FTchange() 437 438" This function checks if one of the first ten lines start with a '@'. In 439" that case it is probably a change file. 440" If the first line starts with # or ! it's probably a ch file. 441" If a line has "main", "include", "//" ir "/*" it's probably ch. 442" Otherwise CHILL is assumed. 443func! s:FTchange() 444 let lnum = 1 445 while lnum <= 10 446 if getline(lnum)[0] == '@' 447 setf change 448 return 449 endif 450 if lnum == 1 && (getline(1)[0] == '#' || getline(1)[0] == '!') 451 setf ch 452 return 453 endif 454 if getline(lnum) =~ "MODULE" 455 setf chill 456 return 457 endif 458 if getline(lnum) =~ 'main\s*(\|#\s*include\|//' 459 setf ch 460 return 461 endif 462 let lnum = lnum + 1 463 endwhile 464 setf chill 465endfunc 466 467" ChordPro 468au BufNewFile,BufRead *.chopro,*.crd,*.cho,*.crdpro,*.chordpro setf chordpro 469 470" Clean 471au BufNewFile,BufRead *.dcl,*.icl setf clean 472 473" Clever 474au BufNewFile,BufRead *.eni setf cl 475 476" Clever or dtd 477au BufNewFile,BufRead *.ent call s:FTent() 478 479func! s:FTent() 480 " This function checks for valid cl syntax in the first five lines. 481 " Look for either an opening comment, '#', or a block start, '{". 482 " If not found, assume SGML. 483 let lnum = 1 484 while lnum < 6 485 let line = getline(lnum) 486 if line =~ '^\s*[#{]' 487 setf cl 488 return 489 elseif line !~ '^\s*$' 490 " Not a blank line, not a comment, and not a block start, 491 " so doesn't look like valid cl code. 492 break 493 endif 494 let lnum = lnum + 1 495 endw 496 setf dtd 497endfunc 498 499" Clipper (or FoxPro; could also be eviews) 500au BufNewFile,BufRead *.prg 501 \ if exists("g:filetype_prg") | 502 \ exe "setf " . g:filetype_prg | 503 \ else | 504 \ setf clipper | 505 \ endif 506 507" Clojure 508au BufNewFile,BufRead *.clj,*.cljs,*.cljx,*.cljc setf clojure 509 510" Cmake 511au BufNewFile,BufRead CMakeLists.txt,*.cmake,*.cmake.in setf cmake 512 513" Cmusrc 514au BufNewFile,BufRead */.cmus/{autosave,rc,command-history,*.theme} setf cmusrc 515au BufNewFile,BufRead */cmus/{rc,*.theme} setf cmusrc 516 517" Cobol 518au BufNewFile,BufRead *.cbl,*.cob,*.lib setf cobol 519" cobol or zope form controller python script? (heuristic) 520au BufNewFile,BufRead *.cpy 521 \ if getline(1) =~ '^##' | 522 \ setf python | 523 \ else | 524 \ setf cobol | 525 \ endif 526 527" Coco/R 528au BufNewFile,BufRead *.atg setf coco 529 530" Cold Fusion 531au BufNewFile,BufRead *.cfm,*.cfi,*.cfc setf cf 532 533" Configure scripts 534au BufNewFile,BufRead configure.in,configure.ac setf config 535 536" CUDA Cumpute Unified Device Architecture 537au BufNewFile,BufRead *.cu setf cuda 538 539" Dockerfile 540au BufNewFile,BufRead Dockerfile,*.Dockerfile setf dockerfile 541 542" WildPackets EtherPeek Decoder 543au BufNewFile,BufRead *.dcd setf dcd 544 545" Enlightenment configuration files 546au BufNewFile,BufRead *enlightenment/*.cfg setf c 547 548" Eterm 549au BufNewFile,BufRead *Eterm/*.cfg setf eterm 550 551" Euphoria 3 or 4 552au BufNewFile,BufRead *.eu,*.ew,*.ex,*.exu,*.exw call s:EuphoriaCheck() 553if has("fname_case") 554 au BufNewFile,BufRead *.EU,*.EW,*.EX,*.EXU,*.EXW call s:EuphoriaCheck() 555endif 556 557func! s:EuphoriaCheck() 558 if exists('g:filetype_euphoria') 559 exe 'setf ' . g:filetype_euphoria 560 else 561 setf euphoria3 562 endif 563endfunc 564 565" Lynx config files 566au BufNewFile,BufRead lynx.cfg setf lynx 567 568" Quake 569au BufNewFile,BufRead *baseq[2-3]/*.cfg,*id1/*.cfg setf quake 570au BufNewFile,BufRead *quake[1-3]/*.cfg setf quake 571 572" Quake C 573au BufNewFile,BufRead *.qc setf c 574 575" Configure files 576au BufNewFile,BufRead *.cfg setf cfg 577 578" Cucumber 579au BufNewFile,BufRead *.feature setf cucumber 580 581" Communicating Sequential Processes 582au BufNewFile,BufRead *.csp,*.fdr setf csp 583 584" CUPL logic description and simulation 585au BufNewFile,BufRead *.pld setf cupl 586au BufNewFile,BufRead *.si setf cuplsim 587 588" Debian Control 589au BufNewFile,BufRead */debian/control setf debcontrol 590au BufNewFile,BufRead control 591 \ if getline(1) =~ '^Source:' 592 \| setf debcontrol 593 \| endif 594 595" Debian Sources.list 596au BufNewFile,BufRead */etc/apt/sources.list setf debsources 597au BufNewFile,BufRead */etc/apt/sources.list.d/*.list setf debsources 598 599" Deny hosts 600au BufNewFile,BufRead denyhosts.conf setf denyhosts 601 602" dnsmasq(8) configuration files 603au BufNewFile,BufRead */etc/dnsmasq.conf setf dnsmasq 604 605" ROCKLinux package description 606au BufNewFile,BufRead *.desc setf desc 607 608" the D language or dtrace 609au BufNewFile,BufRead *.d call s:DtraceCheck() 610 611func! s:DtraceCheck() 612 let lines = getline(1, min([line("$"), 100])) 613 if match(lines, '^module\>\|^import\>') > -1 614 " D files often start with a module and/or import statement. 615 setf d 616 elseif match(lines, '^#!\S\+dtrace\|#pragma\s\+D\s\+option\|:\S\{-}:\S\{-}:') > -1 617 setf dtrace 618 else 619 setf d 620 endif 621endfunc 622 623" Desktop files 624au BufNewFile,BufRead *.desktop,.directory setf desktop 625 626" Dict config 627au BufNewFile,BufRead dict.conf,.dictrc setf dictconf 628 629" Dictd config 630au BufNewFile,BufRead dictd.conf setf dictdconf 631 632" Diff files 633au BufNewFile,BufRead *.diff,*.rej,*.patch setf diff 634 635" Dircolors 636au BufNewFile,BufRead .dir_colors,.dircolors,*/etc/DIR_COLORS setf dircolors 637 638" Diva (with Skill) or InstallShield 639au BufNewFile,BufRead *.rul 640 \ if getline(1).getline(2).getline(3).getline(4).getline(5).getline(6) =~? 'InstallShield' | 641 \ setf ishd | 642 \ else | 643 \ setf diva | 644 \ endif 645 646" DCL (Digital Command Language - vms) or DNS zone file 647au BufNewFile,BufRead *.com call s:BindzoneCheck('dcl') 648 649" DOT 650au BufNewFile,BufRead *.dot setf dot 651 652" Dylan - lid files 653au BufNewFile,BufRead *.lid setf dylanlid 654 655" Dylan - intr files (melange) 656au BufNewFile,BufRead *.intr setf dylanintr 657 658" Dylan 659au BufNewFile,BufRead *.dylan setf dylan 660 661" Microsoft Module Definition 662au BufNewFile,BufRead *.def setf def 663 664" Dracula 665au BufNewFile,BufRead *.drac,*.drc,*lvs,*lpe setf dracula 666 667" Datascript 668au BufNewFile,BufRead *.ds setf datascript 669 670" dsl 671au BufNewFile,BufRead *.dsl setf dsl 672 673" DTD (Document Type Definition for XML) 674au BufNewFile,BufRead *.dtd setf dtd 675 676" DTS/DSTI (device tree files) 677au BufNewFile,BufRead *.dts,*.dtsi setf dts 678 679" EDIF (*.edf,*.edif,*.edn,*.edo) or edn 680au BufNewFile,BufRead *.ed\(f\|if\|o\) setf edif 681au BufNewFile,BufRead *.edn 682 \ if getline(1) =~ '^\s*(\s*edif\>' | 683 \ setf edif | 684 \ else | 685 \ setf clojure | 686 \ endif 687 688" EditorConfig (close enough to dosini) 689au BufNewFile,BufRead .editorconfig setf dosini 690 691" Embedix Component Description 692au BufNewFile,BufRead *.ecd setf ecd 693 694" Eiffel or Specman or Euphoria 695au BufNewFile,BufRead *.e,*.E call s:FTe() 696 697" Elinks configuration 698au BufNewFile,BufRead */etc/elinks.conf,*/.elinks/elinks.conf setf elinks 699 700func! s:FTe() 701 if exists('g:filetype_euphoria') 702 exe 'setf ' . g:filetype_euphoria 703 else 704 let n = 1 705 while n < 100 && n < line("$") 706 if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$" 707 setf specman 708 return 709 endif 710 let n = n + 1 711 endwhile 712 setf eiffel 713 endif 714endfunc 715 716" ERicsson LANGuage; Yaws is erlang too 717au BufNewFile,BufRead *.erl,*.hrl,*.yaws setf erlang 718 719" Elm Filter Rules file 720au BufNewFile,BufRead filter-rules setf elmfilt 721 722" ESMTP rc file 723au BufNewFile,BufRead *esmtprc setf esmtprc 724 725" ESQL-C 726au BufNewFile,BufRead *.ec,*.EC setf esqlc 727 728" Esterel 729au BufNewFile,BufRead *.strl setf esterel 730 731" Essbase script 732au BufNewFile,BufRead *.csc setf csc 733 734" Exim 735au BufNewFile,BufRead exim.conf setf exim 736 737" Expect 738au BufNewFile,BufRead *.exp setf expect 739 740" Exports 741au BufNewFile,BufRead exports setf exports 742 743" Falcon 744au BufNewFile,BufRead *.fal setf falcon 745 746" Fantom 747au BufNewFile,BufRead *.fan,*.fwt setf fan 748 749" Factor 750au BufNewFile,BufRead *.factor setf factor 751 752" Fetchmail RC file 753au BufNewFile,BufRead .fetchmailrc setf fetchmail 754 755" FlexWiki - disabled, because it has side effects when a .wiki file 756" is not actually FlexWiki 757"au BufNewFile,BufRead *.wiki setf flexwiki 758 759" Focus Executable 760au BufNewFile,BufRead *.fex,*.focexec setf focexec 761 762" Focus Master file (but not for auto.master) 763au BufNewFile,BufRead auto.master setf conf 764au BufNewFile,BufRead *.mas,*.master setf master 765 766" Forth 767au BufNewFile,BufRead *.fs,*.ft setf forth 768 769" Reva Forth 770au BufNewFile,BufRead *.frt setf reva 771 772" Fortran 773if has("fname_case") 774 au BufNewFile,BufRead *.F,*.FOR,*.FPP,*.FTN,*.F77,*.F90,*.F95,*.F03,*.F08 setf fortran 775endif 776au BufNewFile,BufRead *.f,*.for,*.fortran,*.fpp,*.ftn,*.f77,*.f90,*.f95,*.f03,*.f08 setf fortran 777 778" Framescript 779au BufNewFile,BufRead *.fsl setf framescript 780 781" FStab 782au BufNewFile,BufRead fstab,mtab setf fstab 783 784" GDB command files 785au BufNewFile,BufRead .gdbinit setf gdb 786 787" GDMO 788au BufNewFile,BufRead *.mo,*.gdmo setf gdmo 789 790" Gedcom 791au BufNewFile,BufRead *.ged,lltxxxxx.txt setf gedcom 792 793" Git 794au BufNewFile,BufRead COMMIT_EDITMSG,MERGE_MSG,TAG_EDITMSG setf gitcommit 795au BufNewFile,BufRead *.git/config,.gitconfig,.gitmodules setf gitconfig 796au BufNewFile,BufRead *.git/modules/*/config setf gitconfig 797au BufNewFile,BufRead */.config/git/config setf gitconfig 798if !empty($XDG_CONFIG_HOME) 799 au BufNewFile,BufRead $XDG_CONFIG_HOME/git/config setf gitconfig 800endif 801au BufNewFile,BufRead git-rebase-todo setf gitrebase 802au BufNewFile,BufRead .msg.[0-9]* 803 \ if getline(1) =~ '^From.*# This line is ignored.$' | 804 \ setf gitsendemail | 805 \ endif 806au BufNewFile,BufRead *.git/* 807 \ if getline(1) =~ '^\x\{40\}\>\|^ref: ' | 808 \ setf git | 809 \ endif 810 811" Gkrellmrc 812au BufNewFile,BufRead gkrellmrc,gkrellmrc_? setf gkrellmrc 813 814" GP scripts (2.0 and onward) 815au BufNewFile,BufRead *.gp,.gprc setf gp 816 817" GPG 818au BufNewFile,BufRead */.gnupg/options setf gpg 819au BufNewFile,BufRead */.gnupg/gpg.conf setf gpg 820au BufNewFile,BufRead */usr/*/gnupg/options.skel setf gpg 821if !empty($GNUPGHOME) 822 au BufNewFile,BufRead $GNUPGHOME/options setf gpg 823 au BufNewFile,BufRead $GNUPGHOME/gpg.conf setf gpg 824endif 825 826" gnash(1) configuration files 827au BufNewFile,BufRead gnashrc,.gnashrc,gnashpluginrc,.gnashpluginrc setf gnash 828 829" Gitolite 830au BufNewFile,BufRead gitolite.conf setf gitolite 831au BufNewFile,BufRead */gitolite-admin/conf/* call s:StarSetf('gitolite') 832au BufNewFile,BufRead {,.}gitolite.rc,example.gitolite.rc setf perl 833 834" Gnuplot scripts 835au BufNewFile,BufRead *.gpi setf gnuplot 836 837" Go (Google) 838au BufNewFile,BufRead *.go setf go 839 840" GrADS scripts 841au BufNewFile,BufRead *.gs setf grads 842 843" Gretl 844au BufNewFile,BufRead *.gretl setf gretl 845 846" Groovy 847au BufNewFile,BufRead *.gradle,*.groovy setf groovy 848 849" GNU Server Pages 850au BufNewFile,BufRead *.gsp setf gsp 851 852" Group file 853au BufNewFile,BufRead */etc/group,*/etc/group-,*/etc/group.edit,*/etc/gshadow,*/etc/gshadow-,*/etc/gshadow.edit,*/var/backups/group.bak,*/var/backups/gshadow.bak setf group 854 855" GTK RC 856au BufNewFile,BufRead .gtkrc,gtkrc setf gtkrc 857 858" Haml 859au BufNewFile,BufRead *.haml setf haml 860 861" Hamster Classic | Playground files 862au BufNewFile,BufRead *.hsc,*.hsm setf hamster 863 864" Haskell 865au BufNewFile,BufRead *.hs,*.hs-boot setf haskell 866au BufNewFile,BufRead *.lhs setf lhaskell 867au BufNewFile,BufRead *.chs setf chaskell 868 869" Haste 870au BufNewFile,BufRead *.ht setf haste 871au BufNewFile,BufRead *.htpp setf hastepreproc 872 873" Hercules 874au BufNewFile,BufRead *.vc,*.ev,*.sum,*.errsum setf hercules 875 876" HEX (Intel) 877au BufNewFile,BufRead *.hex,*.h32 setf hex 878 879" Tilde (must be before HTML) 880au BufNewFile,BufRead *.t.html setf tilde 881 882" HTML (.shtml and .stm for server side) 883au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm call s:FThtml() 884 885" Distinguish between HTML, XHTML and Django 886func! s:FThtml() 887 let n = 1 888 while n < 10 && n < line("$") 889 if getline(n) =~ '\<DTD\s\+XHTML\s' 890 setf xhtml 891 return 892 endif 893 if getline(n) =~ '{%\s*\(extends\|block\|load\)\>\|{#\s\+' 894 setf htmldjango 895 return 896 endif 897 let n = n + 1 898 endwhile 899 setf html 900endfunc 901 902" HTML with Ruby - eRuby 903au BufNewFile,BufRead *.erb,*.rhtml setf eruby 904 905" HTML with M4 906au BufNewFile,BufRead *.html.m4 setf htmlm4 907 908" HTML Cheetah template 909au BufNewFile,BufRead *.tmpl setf htmlcheetah 910 911" Host config 912au BufNewFile,BufRead */etc/host.conf setf hostconf 913 914" Hosts access 915au BufNewFile,BufRead */etc/hosts.allow,*/etc/hosts.deny setf hostsaccess 916 917" Hyper Builder 918au BufNewFile,BufRead *.hb setf hb 919 920" Httest 921au BufNewFile,BufRead *.htt,*.htb setf httest 922 923" Icon 924au BufNewFile,BufRead *.icn setf icon 925 926" IDL (Interface Description Language) 927au BufNewFile,BufRead *.idl call s:FTidl() 928 929" Distinguish between standard IDL and MS-IDL 930func! s:FTidl() 931 let n = 1 932 while n < 50 && n < line("$") 933 if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"' 934 setf msidl 935 return 936 endif 937 let n = n + 1 938 endwhile 939 setf idl 940endfunc 941 942" Microsoft IDL (Interface Description Language) Also *.idl 943" MOF = WMI (Windows Management Instrumentation) Managed Object Format 944au BufNewFile,BufRead *.odl,*.mof setf msidl 945 946" Icewm menu 947au BufNewFile,BufRead */.icewm/menu setf icemenu 948 949" Indent profile (must come before IDL *.pro!) 950au BufNewFile,BufRead .indent.pro setf indent 951au BufNewFile,BufRead indent.pro call s:ProtoCheck('indent') 952 953" IDL (Interactive Data Language) 954au BufNewFile,BufRead *.pro call s:ProtoCheck('idlang') 955 956" Distinguish between "default" and Cproto prototype file. */ 957func! s:ProtoCheck(default) 958 " Cproto files have a comment in the first line and a function prototype in 959 " the second line, it always ends in ";". Indent files may also have 960 " comments, thus we can't match comments to see the difference. 961 " IDL files can have a single ';' in the second line, require at least one 962 " chacter before the ';'. 963 if getline(2) =~ '.;$' 964 setf cpp 965 else 966 exe 'setf ' . a:default 967 endif 968endfunc 969 970 971" Indent RC 972au BufNewFile,BufRead indentrc setf indent 973 974" Inform 975au BufNewFile,BufRead *.inf,*.INF setf inform 976 977" Initng 978au BufNewFile,BufRead */etc/initng/*/*.i,*.ii setf initng 979 980" Innovation Data Processing 981au BufRead,BufNewFile upstream.dat\c,upstream.*.dat\c,*.upstream.dat\c setf upstreamdat 982au BufRead,BufNewFile upstream.log\c,upstream.*.log\c,*.upstream.log\c setf upstreamlog 983au BufRead,BufNewFile upstreaminstall.log\c,upstreaminstall.*.log\c,*.upstreaminstall.log\c setf upstreaminstalllog 984au BufRead,BufNewFile usserver.log\c,usserver.*.log\c,*.usserver.log\c setf usserverlog 985au BufRead,BufNewFile usw2kagt.log\c,usw2kagt.*.log\c,*.usw2kagt.log\c setf usw2kagtlog 986 987" Ipfilter 988au BufNewFile,BufRead ipf.conf,ipf6.conf,ipf.rules setf ipfilter 989 990" Informix 4GL (source - canonical, include file, I4GL+M4 preproc.) 991au BufNewFile,BufRead *.4gl,*.4gh,*.m4gl setf fgl 992 993" .INI file for MSDOS 994au BufNewFile,BufRead *.ini setf dosini 995 996" SysV Inittab 997au BufNewFile,BufRead inittab setf inittab 998 999" Inno Setup 1000au BufNewFile,BufRead *.iss setf iss 1001 1002" J 1003au BufNewFile,BufRead *.ijs setf j 1004 1005" JAL 1006au BufNewFile,BufRead *.jal,*.JAL setf jal 1007 1008" Jam 1009au BufNewFile,BufRead *.jpl,*.jpr setf jam 1010 1011" Java 1012au BufNewFile,BufRead *.java,*.jav setf java 1013 1014" JavaCC 1015au BufNewFile,BufRead *.jj,*.jjt setf javacc 1016 1017" JavaScript, ECMAScript 1018au BufNewFile,BufRead *.js,*.javascript,*.es,*.jsx setf javascript 1019 1020" Java Server Pages 1021au BufNewFile,BufRead *.jsp setf jsp 1022 1023" Java Properties resource file (note: doesn't catch font.properties.pl) 1024au BufNewFile,BufRead *.properties,*.properties_??,*.properties_??_?? setf jproperties 1025au BufNewFile,BufRead *.properties_??_??_* call s:StarSetf('jproperties') 1026 1027" Jess 1028au BufNewFile,BufRead *.clp setf jess 1029 1030" Jgraph 1031au BufNewFile,BufRead *.jgr setf jgraph 1032 1033" Jovial 1034au BufNewFile,BufRead *.jov,*.j73,*.jovial setf jovial 1035 1036" JSON 1037au BufNewFile,BufRead *.json,*.jsonp,*.webmanifest setf json 1038 1039" Kixtart 1040au BufNewFile,BufRead *.kix setf kix 1041 1042" Kimwitu[++] 1043au BufNewFile,BufRead *.k setf kwt 1044 1045" Kivy 1046au BufNewFile,BufRead *.kv setf kivy 1047 1048" KDE script 1049au BufNewFile,BufRead *.ks setf kscript 1050 1051" Kconfig 1052au BufNewFile,BufRead Kconfig,Kconfig.debug setf kconfig 1053 1054" Lace (ISE) 1055au BufNewFile,BufRead *.ace,*.ACE setf lace 1056 1057" Latte 1058au BufNewFile,BufRead *.latte,*.lte setf latte 1059 1060" Limits 1061au BufNewFile,BufRead */etc/limits,*/etc/*limits.conf,*/etc/*limits.d/*.conf setf limits 1062 1063" LambdaProlog (*.mod too, see Modsim) 1064au BufNewFile,BufRead *.sig setf lprolog 1065 1066" LDAP LDIF 1067au BufNewFile,BufRead *.ldif setf ldif 1068 1069" Ld loader 1070au BufNewFile,BufRead *.ld setf ld 1071 1072" Less 1073au BufNewFile,BufRead *.less setf less 1074 1075" Lex 1076au BufNewFile,BufRead *.lex,*.l,*.lxx,*.l++ setf lex 1077 1078" Libao 1079au BufNewFile,BufRead */etc/libao.conf,*/.libao setf libao 1080 1081" Libsensors 1082au BufNewFile,BufRead */etc/sensors.conf,*/etc/sensors3.conf setf sensors 1083 1084" LFTP 1085au BufNewFile,BufRead lftp.conf,.lftprc,*lftp/rc setf lftp 1086 1087" Lifelines (or Lex for C++!) 1088au BufNewFile,BufRead *.ll setf lifelines 1089 1090" Lilo: Linux loader 1091au BufNewFile,BufRead lilo.conf setf lilo 1092 1093" Lisp (*.el = ELisp, *.cl = Common Lisp, *.jl = librep Lisp) 1094if has("fname_case") 1095 au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,*.L,.emacs,.sawfishrc setf lisp 1096else 1097 au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,.emacs,.sawfishrc setf lisp 1098endif 1099 1100" SBCL implementation of Common Lisp 1101au BufNewFile,BufRead sbclrc,.sbclrc setf lisp 1102 1103" Liquid 1104au BufNewFile,BufRead *.liquid setf liquid 1105 1106" Lite 1107au BufNewFile,BufRead *.lite,*.lt setf lite 1108 1109" LiteStep RC files 1110au BufNewFile,BufRead */LiteStep/*/*.rc setf litestep 1111 1112" Login access 1113au BufNewFile,BufRead */etc/login.access setf loginaccess 1114 1115" Login defs 1116au BufNewFile,BufRead */etc/login.defs setf logindefs 1117 1118" Logtalk 1119au BufNewFile,BufRead *.lgt setf logtalk 1120 1121" LOTOS 1122au BufNewFile,BufRead *.lot,*.lotos setf lotos 1123 1124" Lout (also: *.lt) 1125au BufNewFile,BufRead *.lou,*.lout setf lout 1126 1127" Lua 1128au BufNewFile,BufRead *.lua setf lua 1129 1130" Luarocks 1131au BufNewFile,BufRead *.rockspec setf lua 1132 1133" Linden Scripting Language (Second Life) 1134au BufNewFile,BufRead *.lsl setf lsl 1135 1136" Lynx style file (or LotusScript!) 1137au BufNewFile,BufRead *.lss setf lss 1138 1139" M4 1140au BufNewFile,BufRead *.m4 1141 \ if expand("<afile>") !~? 'html.m4$\|fvwm2rc' | setf m4 | endif 1142 1143" MaGic Point 1144au BufNewFile,BufRead *.mgp setf mgp 1145 1146" Mail (for Elm, trn, mutt, muttng, rn, slrn) 1147au BufNewFile,BufRead snd.\d\+,.letter,.letter.\d\+,.followup,.article,.article.\d\+,pico.\d\+,mutt{ng,}-*-\w\+,mutt[[:alnum:]_-]\\\{6\},ae\d\+.txt,/tmp/SLRN[0-9A-Z.]\+,*.eml setf mail 1148 1149" Mail aliases 1150au BufNewFile,BufRead */etc/mail/aliases,*/etc/aliases setf mailaliases 1151 1152" Mailcap configuration file 1153au BufNewFile,BufRead .mailcap,mailcap setf mailcap 1154 1155" Makefile 1156au BufNewFile,BufRead *[mM]akefile,*.mk,*.mak,*.dsp setf make 1157 1158" MakeIndex 1159au BufNewFile,BufRead *.ist,*.mst setf ist 1160 1161" Mallard 1162au BufNewFile,BufRead *.page setf mallard 1163 1164" Manpage 1165au BufNewFile,BufRead *.man setf man 1166 1167" Man config 1168au BufNewFile,BufRead */etc/man.conf,man.config setf manconf 1169 1170" Maple V 1171au BufNewFile,BufRead *.mv,*.mpl,*.mws setf maple 1172 1173" Map (UMN mapserver config file) 1174au BufNewFile,BufRead *.map setf map 1175 1176" Markdown 1177au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,*.mdwn,*.md setf markdown 1178 1179" Mason 1180au BufNewFile,BufRead *.mason,*.mhtml,*.comp setf mason 1181 1182" Matlab or Objective C 1183au BufNewFile,BufRead *.m call s:FTm() 1184 1185func! s:FTm() 1186 let n = 1 1187 while n < 10 1188 let line = getline(n) 1189 if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|/\*\|//\)' 1190 setf objc 1191 return 1192 endif 1193 if line =~ '^\s*%' 1194 setf matlab 1195 return 1196 endif 1197 if line =~ '^\s*(\*' 1198 setf mma 1199 return 1200 endif 1201 let n = n + 1 1202 endwhile 1203 if exists("g:filetype_m") 1204 exe "setf " . g:filetype_m 1205 else 1206 setf matlab 1207 endif 1208endfunc 1209 1210" Mathematica notebook 1211au BufNewFile,BufRead *.nb setf mma 1212 1213" Maya Extension Language 1214au BufNewFile,BufRead *.mel setf mel 1215 1216" Mercurial (hg) commit file 1217au BufNewFile,BufRead hg-editor-*.txt setf hgcommit 1218 1219" Mercurial config (looks like generic config file) 1220au BufNewFile,BufRead *.hgrc,*hgrc setf cfg 1221 1222" Messages (logs mostly) 1223au BufNewFile,BufRead */log/{auth,cron,daemon,debug,kern,lpr,mail,messages,news/news,syslog,user}{,.log,.err,.info,.warn,.crit,.notice}{,.[0-9]*,-[0-9]*} setf messages 1224 1225" Metafont 1226au BufNewFile,BufRead *.mf setf mf 1227 1228" MetaPost 1229au BufNewFile,BufRead *.mp setf mp 1230 1231" MGL 1232au BufNewFile,BufRead *.mgl setf mgl 1233 1234" MIX - Knuth assembly 1235au BufNewFile,BufRead *.mix,*.mixal setf mix 1236 1237" MMIX or VMS makefile 1238au BufNewFile,BufRead *.mms call s:FTmms() 1239 1240" Symbian meta-makefile definition (MMP) 1241au BufNewFile,BufRead *.mmp setf mmp 1242 1243func! s:FTmms() 1244 let n = 1 1245 while n < 10 1246 let line = getline(n) 1247 if line =~ '^\s*\(%\|//\)' || line =~ '^\*' 1248 setf mmix 1249 return 1250 endif 1251 if line =~ '^\s*#' 1252 setf make 1253 return 1254 endif 1255 let n = n + 1 1256 endwhile 1257 setf mmix 1258endfunc 1259 1260 1261" Modsim III (or LambdaProlog) 1262au BufNewFile,BufRead *.mod 1263 \ if getline(1) =~ '\<module\>' | 1264 \ setf lprolog | 1265 \ else | 1266 \ setf modsim3 | 1267 \ endif 1268 1269" Modula 2 (.md removed in favor of Markdown) 1270au BufNewFile,BufRead *.m2,*.DEF,*.MOD,*.mi setf modula2 1271 1272" Modula 3 (.m3, .i3, .mg, .ig) 1273au BufNewFile,BufRead *.[mi][3g] setf modula3 1274 1275" Monk 1276au BufNewFile,BufRead *.isc,*.monk,*.ssc,*.tsc setf monk 1277 1278" MOO 1279au BufNewFile,BufRead *.moo setf moo 1280 1281" Modconf 1282au BufNewFile,BufRead */etc/modules.conf,*/etc/modules,*/etc/conf.modules setf modconf 1283 1284" Mplayer config 1285au BufNewFile,BufRead mplayer.conf,*/.mplayer/config setf mplayerconf 1286 1287" Motorola S record 1288au BufNewFile,BufRead *.s19,*.s28,*.s37,*.mot,*.srec setf srec 1289 1290" Mrxvtrc 1291au BufNewFile,BufRead mrxvtrc,.mrxvtrc setf mrxvtrc 1292 1293" Msql 1294au BufNewFile,BufRead *.msql setf msql 1295 1296" Mysql 1297au BufNewFile,BufRead *.mysql setf mysql 1298 1299" Mutt setup files (must be before catch *.rc) 1300au BufNewFile,BufRead */etc/Muttrc.d/* call s:StarSetf('muttrc') 1301 1302" M$ Resource files 1303au BufNewFile,BufRead *.rc,*.rch setf rc 1304 1305" MuPAD source 1306au BufRead,BufNewFile *.mu setf mupad 1307 1308" Mush 1309au BufNewFile,BufRead *.mush setf mush 1310 1311" Mutt setup file (also for Muttng) 1312au BufNewFile,BufRead Mutt{ng,}rc setf muttrc 1313 1314" Nano 1315au BufNewFile,BufRead */etc/nanorc,*.nanorc setf nanorc 1316 1317" Nastran input/DMAP 1318"au BufNewFile,BufRead *.dat setf nastran 1319 1320" Natural 1321au BufNewFile,BufRead *.NS[ACGLMNPS] setf natural 1322 1323" Netrc 1324au BufNewFile,BufRead .netrc setf netrc 1325 1326" Ninja file 1327au BufNewFile,BufRead *.ninja setf ninja 1328 1329" Novell netware batch files 1330au BufNewFile,BufRead *.ncf setf ncf 1331 1332" Nroff/Troff (*.ms and *.t are checked below) 1333au BufNewFile,BufRead *.me 1334 \ if expand("<afile>") != "read.me" && expand("<afile>") != "click.me" | 1335 \ setf nroff | 1336 \ endif 1337au BufNewFile,BufRead *.tr,*.nr,*.roff,*.tmac,*.mom setf nroff 1338au BufNewFile,BufRead *.[1-9] call s:FTnroff() 1339 1340" This function checks if one of the first five lines start with a dot. In 1341" that case it is probably an nroff file: 'filetype' is set and 1 is returned. 1342func! s:FTnroff() 1343 if getline(1)[0] . getline(2)[0] . getline(3)[0] . getline(4)[0] . getline(5)[0] =~ '\.' 1344 setf nroff 1345 return 1 1346 endif 1347 return 0 1348endfunc 1349 1350" Nroff or Objective C++ 1351au BufNewFile,BufRead *.mm call s:FTmm() 1352 1353func! s:FTmm() 1354 let n = 1 1355 while n < 10 1356 let line = getline(n) 1357 if line =~ '^\s*\(#\s*\(include\|import\)\>\|@import\>\|/\*\)' 1358 setf objcpp 1359 return 1360 endif 1361 let n = n + 1 1362 endwhile 1363 setf nroff 1364endfunc 1365 1366" Not Quite C 1367au BufNewFile,BufRead *.nqc setf nqc 1368 1369" NSE - Nmap Script Engine - uses Lua syntax 1370au BufNewFile,BufRead *.nse setf lua 1371 1372" NSIS 1373au BufNewFile,BufRead *.nsi,*.nsh setf nsis 1374 1375" OCAML 1376au BufNewFile,BufRead *.ml,*.mli,*.mll,*.mly,.ocamlinit setf ocaml 1377 1378" Occam 1379au BufNewFile,BufRead *.occ setf occam 1380 1381" Omnimark 1382au BufNewFile,BufRead *.xom,*.xin setf omnimark 1383 1384" OpenROAD 1385au BufNewFile,BufRead *.or setf openroad 1386 1387" OPL 1388au BufNewFile,BufRead *.[Oo][Pp][Ll] setf opl 1389 1390" Oracle config file 1391au BufNewFile,BufRead *.ora setf ora 1392 1393" Packet filter conf 1394au BufNewFile,BufRead pf.conf setf pf 1395 1396" Pam conf 1397au BufNewFile,BufRead */etc/pam.conf setf pamconf 1398 1399" PApp 1400au BufNewFile,BufRead *.papp,*.pxml,*.pxsl setf papp 1401 1402" Password file 1403au BufNewFile,BufRead */etc/passwd,*/etc/passwd-,*/etc/passwd.edit,*/etc/shadow,*/etc/shadow-,*/etc/shadow.edit,*/var/backups/passwd.bak,*/var/backups/shadow.bak setf passwd 1404 1405" Pascal (also *.p) 1406au BufNewFile,BufRead *.pas setf pascal 1407 1408" Delphi project file 1409au BufNewFile,BufRead *.dpr setf pascal 1410 1411" PDF 1412au BufNewFile,BufRead *.pdf setf pdf 1413 1414" Perl 1415if has("fname_case") 1416 au BufNewFile,BufRead *.pl,*.PL call s:FTpl() 1417else 1418 au BufNewFile,BufRead *.pl call s:FTpl() 1419endif 1420au BufNewFile,BufRead *.plx,*.al setf perl 1421au BufNewFile,BufRead *.p6,*.pm6,*.pl6 setf perl6 1422 1423func! s:FTpl() 1424 if exists("g:filetype_pl") 1425 exe "setf " . g:filetype_pl 1426 else 1427 " recognize Prolog by specific text in the first non-empty line 1428 " require a blank after the '%' because Perl uses "%list" and "%translate" 1429 let l = getline(nextnonblank(1)) 1430 if l =~ '\<prolog\>' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-' 1431 setf prolog 1432 else 1433 setf perl 1434 endif 1435 endif 1436endfunc 1437 1438" Perl, XPM or XPM2 1439au BufNewFile,BufRead *.pm 1440 \ if getline(1) =~ "XPM2" | 1441 \ setf xpm2 | 1442 \ elseif getline(1) =~ "XPM" | 1443 \ setf xpm | 1444 \ else | 1445 \ setf perl | 1446 \ endif 1447 1448" Perl POD 1449au BufNewFile,BufRead *.pod setf pod 1450au BufNewFile,BufRead *.pod6 setf pod6 1451 1452" Php, php3, php4, etc. 1453" Also Phtml (was used for PHP 2 in the past) 1454" Also .ctp for Cake template file 1455au BufNewFile,BufRead *.php,*.php\d,*.phtml,*.ctp setf php 1456 1457" Pike 1458au BufNewFile,BufRead *.pike,*.lpc,*.ulpc,*.pmod setf pike 1459 1460" Pinfo config 1461au BufNewFile,BufRead */etc/pinforc,*/.pinforc setf pinfo 1462 1463" Palm Resource compiler 1464au BufNewFile,BufRead *.rcp setf pilrc 1465 1466" Pine config 1467au BufNewFile,BufRead .pinerc,pinerc,.pinercex,pinercex setf pine 1468 1469" PL/1, PL/I 1470au BufNewFile,BufRead *.pli,*.pl1 setf pli 1471 1472" PL/M (also: *.inp) 1473au BufNewFile,BufRead *.plm,*.p36,*.pac setf plm 1474 1475" PL/SQL 1476au BufNewFile,BufRead *.pls,*.plsql setf plsql 1477 1478" PLP 1479au BufNewFile,BufRead *.plp setf plp 1480 1481" PO and PO template (GNU gettext) 1482au BufNewFile,BufRead *.po,*.pot setf po 1483 1484" Postfix main config 1485au BufNewFile,BufRead main.cf setf pfmain 1486 1487" PostScript (+ font files, encapsulated PostScript, Adobe Illustrator) 1488au BufNewFile,BufRead *.ps,*.pfa,*.afm,*.eps,*.epsf,*.epsi,*.ai setf postscr 1489 1490" PostScript Printer Description 1491au BufNewFile,BufRead *.ppd setf ppd 1492 1493" Povray 1494au BufNewFile,BufRead *.pov setf pov 1495 1496" Povray configuration 1497au BufNewFile,BufRead .povrayrc setf povini 1498 1499" Povray, PHP or assembly 1500au BufNewFile,BufRead *.inc call s:FTinc() 1501 1502func! s:FTinc() 1503 if exists("g:filetype_inc") 1504 exe "setf " . g:filetype_inc 1505 else 1506 let lines = getline(1).getline(2).getline(3) 1507 if lines =~? "perlscript" 1508 setf aspperl 1509 elseif lines =~ "<%" 1510 setf aspvbs 1511 elseif lines =~ "<?" 1512 setf php 1513 else 1514 call s:FTasmsyntax() 1515 if exists("b:asmsyntax") 1516 exe "setf " . fnameescape(b:asmsyntax) 1517 else 1518 setf pov 1519 endif 1520 endif 1521 endif 1522endfunc 1523 1524" Printcap and Termcap 1525au BufNewFile,BufRead *printcap 1526 \ let b:ptcap_type = "print" | setf ptcap 1527au BufNewFile,BufRead *termcap 1528 \ let b:ptcap_type = "term" | setf ptcap 1529 1530" PCCTS / ANTRL 1531"au BufNewFile,BufRead *.g setf antrl 1532au BufNewFile,BufRead *.g setf pccts 1533 1534" PPWizard 1535au BufNewFile,BufRead *.it,*.ih setf ppwiz 1536 1537" Obj 3D file format 1538" TODO: is there a way to avoid MS-Windows Object files? 1539au BufNewFile,BufRead *.obj setf obj 1540 1541" Oracle Pro*C/C++ 1542au BufNewFile,BufRead *.pc setf proc 1543 1544" Privoxy actions file 1545au BufNewFile,BufRead *.action setf privoxy 1546 1547" Procmail 1548au BufNewFile,BufRead .procmail,.procmailrc setf procmail 1549 1550" Progress or CWEB 1551au BufNewFile,BufRead *.w call s:FTprogress_cweb() 1552 1553func! s:FTprogress_cweb() 1554 if exists("g:filetype_w") 1555 exe "setf " . g:filetype_w 1556 return 1557 endif 1558 if getline(1) =~ '&ANALYZE' || getline(3) =~ '&GLOBAL-DEFINE' 1559 setf progress 1560 else 1561 setf cweb 1562 endif 1563endfunc 1564 1565" Progress or assembly 1566au BufNewFile,BufRead *.i call s:FTprogress_asm() 1567 1568func! s:FTprogress_asm() 1569 if exists("g:filetype_i") 1570 exe "setf " . g:filetype_i 1571 return 1572 endif 1573 " This function checks for an assembly comment the first ten lines. 1574 " If not found, assume Progress. 1575 let lnum = 1 1576 while lnum <= 10 && lnum < line('$') 1577 let line = getline(lnum) 1578 if line =~ '^\s*;' || line =~ '^\*' 1579 call s:FTasm() 1580 return 1581 elseif line !~ '^\s*$' || line =~ '^/\*' 1582 " Not an empty line: Doesn't look like valid assembly code. 1583 " Or it looks like a Progress /* comment 1584 break 1585 endif 1586 let lnum = lnum + 1 1587 endw 1588 setf progress 1589endfunc 1590 1591" Progress or Pascal 1592au BufNewFile,BufRead *.p call s:FTprogress_pascal() 1593 1594func! s:FTprogress_pascal() 1595 if exists("g:filetype_p") 1596 exe "setf " . g:filetype_p 1597 return 1598 endif 1599 " This function checks for valid Pascal syntax in the first ten lines. 1600 " Look for either an opening comment or a program start. 1601 " If not found, assume Progress. 1602 let lnum = 1 1603 while lnum <= 10 && lnum < line('$') 1604 let line = getline(lnum) 1605 if line =~ '^\s*\(program\|unit\|procedure\|function\|const\|type\|var\)\>' 1606 \ || line =~ '^\s*{' || line =~ '^\s*(\*' 1607 setf pascal 1608 return 1609 elseif line !~ '^\s*$' || line =~ '^/\*' 1610 " Not an empty line: Doesn't look like valid Pascal code. 1611 " Or it looks like a Progress /* comment 1612 break 1613 endif 1614 let lnum = lnum + 1 1615 endw 1616 setf progress 1617endfunc 1618 1619 1620" Software Distributor Product Specification File (POSIX 1387.2-1995) 1621au BufNewFile,BufRead *.psf setf psf 1622au BufNewFile,BufRead INDEX,INFO 1623 \ if getline(1) =~ '^\s*\(distribution\|installed_software\|root\|bundle\|product\)\s*$' | 1624 \ setf psf | 1625 \ endif 1626 1627" Prolog 1628au BufNewFile,BufRead *.pdb setf prolog 1629 1630" Promela 1631au BufNewFile,BufRead *.pml setf promela 1632 1633" Google protocol buffers 1634au BufNewFile,BufRead *.proto setf proto 1635 1636" Protocols 1637au BufNewFile,BufRead */etc/protocols setf protocols 1638 1639" Pyrex 1640au BufNewFile,BufRead *.pyx,*.pxd setf pyrex 1641 1642" Python, Python Shell Startup Files 1643" Quixote (Python-based web framework) 1644au BufNewFile,BufRead *.py,*.pyw,.pythonstartup,.pythonrc,*.ptl setf python 1645 1646" Radiance 1647au BufNewFile,BufRead *.rad,*.mat setf radiance 1648 1649" Ratpoison config/command files 1650au BufNewFile,BufRead .ratpoisonrc,ratpoisonrc setf ratpoison 1651 1652" RCS file 1653au BufNewFile,BufRead *\,v setf rcs 1654 1655" Readline 1656au BufNewFile,BufRead .inputrc,inputrc setf readline 1657 1658" Registry for MS-Windows 1659au BufNewFile,BufRead *.reg 1660 \ if getline(1) =~? '^REGEDIT[0-9]*\s*$\|^Windows Registry Editor Version \d*\.\d*\s*$' | setf registry | endif 1661 1662" Renderman Interface Bytestream 1663au BufNewFile,BufRead *.rib setf rib 1664 1665" Rexx 1666au BufNewFile,BufRead *.rex,*.orx,*.rxo,*.rxj,*.jrexx,*.rexxj,*.rexx,*.testGroup,*.testUnit setf rexx 1667 1668" R (Splus) 1669if has("fname_case") 1670 au BufNewFile,BufRead *.s,*.S setf r 1671else 1672 au BufNewFile,BufRead *.s setf r 1673endif 1674 1675" R Help file 1676if has("fname_case") 1677 au BufNewFile,BufRead *.rd,*.Rd setf rhelp 1678else 1679 au BufNewFile,BufRead *.rd setf rhelp 1680endif 1681 1682" R noweb file 1683if has("fname_case") 1684 au BufNewFile,BufRead *.Rnw,*.rnw,*.Snw,*.snw setf rnoweb 1685else 1686 au BufNewFile,BufRead *.rnw,*.snw setf rnoweb 1687endif 1688 1689" R Markdown file 1690if has("fname_case") 1691 au BufNewFile,BufRead *.Rmd,*.rmd,*.Smd,*.smd setf rmd 1692else 1693 au BufNewFile,BufRead *.rmd,*.smd setf rmd 1694endif 1695 1696" R reStructuredText file 1697if has("fname_case") 1698 au BufNewFile,BufRead *.Rrst,*.rrst,*.Srst,*.srst setf rrst 1699else 1700 au BufNewFile,BufRead *.rrst,*.srst setf rrst 1701endif 1702 1703" Rexx, Rebol or R 1704au BufNewFile,BufRead *.r,*.R call s:FTr() 1705 1706func! s:FTr() 1707 let max = line("$") > 50 ? 50 : line("$") 1708 1709 for n in range(1, max) 1710 " Rebol is easy to recognize, check for that first 1711 if getline(n) =~? '\<REBOL\>' 1712 setf rebol 1713 return 1714 endif 1715 endfor 1716 1717 for n in range(1, max) 1718 " R has # comments 1719 if getline(n) =~ '^\s*#' 1720 setf r 1721 return 1722 endif 1723 " Rexx has /* comments */ 1724 if getline(n) =~ '^\s*/\*' 1725 setf rexx 1726 return 1727 endif 1728 endfor 1729 1730 " Nothing recognized, use user default or assume Rexx 1731 if exists("g:filetype_r") 1732 exe "setf " . g:filetype_r 1733 else 1734 " Rexx used to be the default, but R appears to be much more popular. 1735 setf r 1736 endif 1737endfunc 1738 1739" Remind 1740au BufNewFile,BufRead .reminders,*.remind,*.rem setf remind 1741 1742" Resolv.conf 1743au BufNewFile,BufRead resolv.conf setf resolv 1744 1745" Relax NG Compact 1746au BufNewFile,BufRead *.rnc setf rnc 1747 1748" Relax NG XML 1749au BufNewFile,BufRead *.rng setf rng 1750 1751" RPL/2 1752au BufNewFile,BufRead *.rpl setf rpl 1753 1754" Robots.txt 1755au BufNewFile,BufRead robots.txt setf robots 1756 1757" Rpcgen 1758au BufNewFile,BufRead *.x setf rpcgen 1759 1760" reStructuredText Documentation Format 1761au BufNewFile,BufRead *.rst setf rst 1762 1763" RTF 1764au BufNewFile,BufRead *.rtf setf rtf 1765 1766" Interactive Ruby shell 1767au BufNewFile,BufRead .irbrc,irbrc setf ruby 1768 1769" Ruby 1770au BufNewFile,BufRead *.rb,*.rbw setf ruby 1771 1772" RubyGems 1773au BufNewFile,BufRead *.gemspec setf ruby 1774 1775" Rust 1776au BufNewFile,BufRead *.rs setf rust 1777 1778" Rackup 1779au BufNewFile,BufRead *.ru setf ruby 1780 1781" Bundler 1782au BufNewFile,BufRead Gemfile setf ruby 1783 1784" Ruby on Rails 1785au BufNewFile,BufRead *.builder,*.rxml,*.rjs setf ruby 1786 1787" Rantfile and Rakefile is like Ruby 1788au BufNewFile,BufRead [rR]antfile,*.rant,[rR]akefile,*.rake setf ruby 1789 1790" S-lang (or shader language, or SmallLisp) 1791au BufNewFile,BufRead *.sl setf slang 1792 1793" Samba config 1794au BufNewFile,BufRead smb.conf setf samba 1795 1796" SAS script 1797au BufNewFile,BufRead *.sas setf sas 1798 1799" Sass 1800au BufNewFile,BufRead *.sass setf sass 1801 1802" Sather 1803au BufNewFile,BufRead *.sa setf sather 1804 1805" Scala 1806au BufNewFile,BufRead *.scala setf scala 1807 1808" Scilab 1809au BufNewFile,BufRead *.sci,*.sce setf scilab 1810 1811" SCSS 1812au BufNewFile,BufRead *.scss setf scss 1813 1814" SD: Streaming Descriptors 1815au BufNewFile,BufRead *.sd setf sd 1816 1817" SDL 1818au BufNewFile,BufRead *.sdl,*.pr setf sdl 1819 1820" sed 1821au BufNewFile,BufRead *.sed setf sed 1822 1823" Sieve (RFC 3028) 1824au BufNewFile,BufRead *.siv setf sieve 1825 1826" Sendmail 1827au BufNewFile,BufRead sendmail.cf setf sm 1828 1829" Sendmail .mc files are actually m4. Could also be MS Message text file. 1830au BufNewFile,BufRead *.mc call s:McSetf() 1831 1832func! s:McSetf() 1833 " Rely on the file to start with a comment. 1834 " MS message text files use ';', Sendmail files use '#' or 'dnl' 1835 for lnum in range(1, min([line("$"), 20])) 1836 let line = getline(lnum) 1837 if line =~ '^\s*\(#\|dnl\)' 1838 setf m4 " Sendmail .mc file 1839 return 1840 elseif line =~ '^\s*;' 1841 setf msmessages " MS Message text file 1842 return 1843 endif 1844 endfor 1845 setf m4 " Default: Sendmail .mc file 1846endfunc 1847 1848" Services 1849au BufNewFile,BufRead */etc/services setf services 1850 1851" Service Location config 1852au BufNewFile,BufRead */etc/slp.conf setf slpconf 1853 1854" Service Location registration 1855au BufNewFile,BufRead */etc/slp.reg setf slpreg 1856 1857" Service Location SPI 1858au BufNewFile,BufRead */etc/slp.spi setf slpspi 1859 1860" Setserial config 1861au BufNewFile,BufRead */etc/serial.conf setf setserial 1862 1863" SGML 1864au BufNewFile,BufRead *.sgm,*.sgml 1865 \ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'linuxdoc' | 1866 \ setf sgmllnx | 1867 \ elseif getline(1) =~ '<!DOCTYPE.*DocBook' || getline(2) =~ '<!DOCTYPE.*DocBook' | 1868 \ let b:docbk_type = "sgml" | 1869 \ let b:docbk_ver = 4 | 1870 \ setf docbk | 1871 \ else | 1872 \ setf sgml | 1873 \ endif 1874 1875" SGMLDECL 1876au BufNewFile,BufRead *.decl,*.dcl,*.dec 1877 \ if getline(1).getline(2).getline(3) =~? '^<!SGML' | 1878 \ setf sgmldecl | 1879 \ endif 1880 1881" SGML catalog file 1882au BufNewFile,BufRead catalog setf catalog 1883au BufNewFile,BufRead sgml.catalog* call s:StarSetf('catalog') 1884 1885" Shell scripts (sh, ksh, bash, bash2, csh); Allow .profile_foo etc. 1886" Gentoo ebuilds and Arch Linux PKGBUILDs are actually bash scripts 1887au BufNewFile,BufRead .bashrc*,bashrc,bash.bashrc,.bash[_-]profile*,.bash[_-]logout*,.bash[_-]aliases*,*.bash,*/{,.}bash[_-]completion{,.d,.sh}{,/*},*.ebuild,*.eclass,PKGBUILD* call SetFileTypeSH("bash") 1888au BufNewFile,BufRead .kshrc*,*.ksh call SetFileTypeSH("ksh") 1889au BufNewFile,BufRead */etc/profile,.profile*,*.sh,*.env call SetFileTypeSH(getline(1)) 1890 1891" Shell script (Arch Linux) or PHP file (Drupal) 1892au BufNewFile,BufRead *.install 1893 \ if getline(1) =~ '<?php' | 1894 \ setf php | 1895 \ else | 1896 \ call SetFileTypeSH("bash") | 1897 \ endif 1898 1899" Also called from scripts.vim. 1900func! SetFileTypeSH(name) 1901 if expand("<amatch>") =~ g:ft_ignore_pat 1902 return 1903 endif 1904 if a:name =~ '\<csh\>' 1905 " Some .sh scripts contain #!/bin/csh. 1906 call SetFileTypeShell("csh") 1907 return 1908 elseif a:name =~ '\<tcsh\>' 1909 " Some .sh scripts contain #!/bin/tcsh. 1910 call SetFileTypeShell("tcsh") 1911 return 1912 elseif a:name =~ '\<zsh\>' 1913 " Some .sh scripts contain #!/bin/zsh. 1914 call SetFileTypeShell("zsh") 1915 return 1916 elseif a:name =~ '\<ksh\>' 1917 let b:is_kornshell = 1 1918 if exists("b:is_bash") 1919 unlet b:is_bash 1920 endif 1921 if exists("b:is_sh") 1922 unlet b:is_sh 1923 endif 1924 elseif exists("g:bash_is_sh") || a:name =~ '\<bash\>' || a:name =~ '\<bash2\>' 1925 let b:is_bash = 1 1926 if exists("b:is_kornshell") 1927 unlet b:is_kornshell 1928 endif 1929 if exists("b:is_sh") 1930 unlet b:is_sh 1931 endif 1932 elseif a:name =~ '\<sh\>' 1933 let b:is_sh = 1 1934 if exists("b:is_kornshell") 1935 unlet b:is_kornshell 1936 endif 1937 if exists("b:is_bash") 1938 unlet b:is_bash 1939 endif 1940 endif 1941 call SetFileTypeShell("sh") 1942endfunc 1943 1944" For shell-like file types, check for an "exec" command hidden in a comment, 1945" as used for Tcl. 1946" Also called from scripts.vim, thus can't be local to this script. 1947func! SetFileTypeShell(name) 1948 if expand("<amatch>") =~ g:ft_ignore_pat 1949 return 1950 endif 1951 let l = 2 1952 while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)' 1953 " Skip empty and comment lines. 1954 let l = l + 1 1955 endwhile 1956 if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$' 1957 " Found an "exec" line after a comment with continuation 1958 let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '') 1959 if n =~ '\<tclsh\|\<wish' 1960 setf tcl 1961 return 1962 endif 1963 endif 1964 exe "setf " . a:name 1965endfunc 1966 1967" tcsh scripts 1968au BufNewFile,BufRead .tcshrc*,*.tcsh,tcsh.tcshrc,tcsh.login call SetFileTypeShell("tcsh") 1969 1970" csh scripts, but might also be tcsh scripts (on some systems csh is tcsh) 1971au BufNewFile,BufRead .login*,.cshrc*,csh.cshrc,csh.login,csh.logout,*.csh,.alias call s:CSH() 1972 1973func! s:CSH() 1974 if exists("g:filetype_csh") 1975 call SetFileTypeShell(g:filetype_csh) 1976 elseif &shell =~ "tcsh" 1977 call SetFileTypeShell("tcsh") 1978 else 1979 call SetFileTypeShell("csh") 1980 endif 1981endfunc 1982 1983" Z-Shell script 1984au BufNewFile,BufRead .zprofile,*/etc/zprofile,.zfbfmarks setf zsh 1985au BufNewFile,BufRead .zsh*,.zlog*,.zcompdump* call s:StarSetf('zsh') 1986au BufNewFile,BufRead *.zsh setf zsh 1987 1988" Scheme 1989au BufNewFile,BufRead *.scm,*.ss,*.rkt setf scheme 1990 1991" Screen RC 1992au BufNewFile,BufRead .screenrc,screenrc setf screen 1993 1994" Simula 1995au BufNewFile,BufRead *.sim setf simula 1996 1997" SINDA 1998au BufNewFile,BufRead *.sin,*.s85 setf sinda 1999 2000" SiSU 2001au BufNewFile,BufRead *.sst,*.ssm,*.ssi,*.-sst,*._sst setf sisu 2002au BufNewFile,BufRead *.sst.meta,*.-sst.meta,*._sst.meta setf sisu 2003 2004" SKILL 2005au BufNewFile,BufRead *.il,*.ils,*.cdf setf skill 2006 2007" SLRN 2008au BufNewFile,BufRead .slrnrc setf slrnrc 2009au BufNewFile,BufRead *.score setf slrnsc 2010 2011" Smalltalk (and TeX) 2012au BufNewFile,BufRead *.st setf st 2013au BufNewFile,BufRead *.cls 2014 \ if getline(1) =~ '^%' | 2015 \ setf tex | 2016 \ elseif getline(1)[0] == '#' && getline(1) =~ 'rexx' | 2017 \ setf rexx | 2018 \ else | 2019 \ setf st | 2020 \ endif 2021 2022" Smarty templates 2023au BufNewFile,BufRead *.tpl setf smarty 2024 2025" SMIL or XML 2026au BufNewFile,BufRead *.smil 2027 \ if getline(1) =~ '<?\s*xml.*?>' | 2028 \ setf xml | 2029 \ else | 2030 \ setf smil | 2031 \ endif 2032 2033" SMIL or SNMP MIB file 2034au BufNewFile,BufRead *.smi 2035 \ if getline(1) =~ '\<smil\>' | 2036 \ setf smil | 2037 \ else | 2038 \ setf mib | 2039 \ endif 2040 2041" SMITH 2042au BufNewFile,BufRead *.smt,*.smith setf smith 2043 2044" Snobol4 and spitbol 2045au BufNewFile,BufRead *.sno,*.spt setf snobol4 2046 2047" SNMP MIB files 2048au BufNewFile,BufRead *.mib,*.my setf mib 2049 2050" Snort Configuration 2051au BufNewFile,BufRead *.hog,snort.conf,vision.conf setf hog 2052au BufNewFile,BufRead *.rules call s:FTRules() 2053 2054let s:ft_rules_udev_rules_pattern = '^\s*\cudev_rules\s*=\s*"\([^"]\{-1,}\)/*".*' 2055func! s:FTRules() 2056 let path = expand('<amatch>:p') 2057 if path =~ '^/\(etc/udev/\%(rules\.d/\)\=.*\.rules\|lib/udev/\%(rules\.d/\)\=.*\.rules\)$' 2058 setf udevrules 2059 return 2060 endif 2061 if path =~ '^/etc/ufw/' 2062 setf conf " Better than hog 2063 return 2064 endif 2065 if path =~ '^/\(etc\|usr/share\)/polkit-1/rules\.d' 2066 setf javascript 2067 return 2068 endif 2069 try 2070 let config_lines = readfile('/etc/udev/udev.conf') 2071 catch /^Vim\%((\a\+)\)\=:E484/ 2072 setf hog 2073 return 2074 endtry 2075 let dir = expand('<amatch>:p:h') 2076 for line in config_lines 2077 if line =~ s:ft_rules_udev_rules_pattern 2078 let udev_rules = substitute(line, s:ft_rules_udev_rules_pattern, '\1', "") 2079 if dir == udev_rules 2080 setf udevrules 2081 endif 2082 break 2083 endif 2084 endfor 2085 setf hog 2086endfunc 2087 2088 2089" Spec (Linux RPM) 2090au BufNewFile,BufRead *.spec setf spec 2091 2092" Speedup (AspenTech plant simulator) 2093au BufNewFile,BufRead *.speedup,*.spdata,*.spd setf spup 2094 2095" Slice 2096au BufNewFile,BufRead *.ice setf slice 2097 2098" Spice 2099au BufNewFile,BufRead *.sp,*.spice setf spice 2100 2101" Spyce 2102au BufNewFile,BufRead *.spy,*.spi setf spyce 2103 2104" Squid 2105au BufNewFile,BufRead squid.conf setf squid 2106 2107" SQL for Oracle Designer 2108au BufNewFile,BufRead *.tyb,*.typ,*.tyc,*.pkb,*.pks setf sql 2109 2110" SQL 2111au BufNewFile,BufRead *.sql call s:SQL() 2112 2113func! s:SQL() 2114 if exists("g:filetype_sql") 2115 exe "setf " . g:filetype_sql 2116 else 2117 setf sql 2118 endif 2119endfunc 2120 2121" SQLJ 2122au BufNewFile,BufRead *.sqlj setf sqlj 2123 2124" SQR 2125au BufNewFile,BufRead *.sqr,*.sqi setf sqr 2126 2127" OpenSSH configuration 2128au BufNewFile,BufRead ssh_config,*/.ssh/config setf sshconfig 2129 2130" OpenSSH server configuration 2131au BufNewFile,BufRead sshd_config setf sshdconfig 2132 2133" Stata 2134au BufNewFile,BufRead *.ado,*.class,*.do,*.imata,*.mata setf stata 2135 2136" SMCL 2137au BufNewFile,BufRead *.hlp,*.ihlp,*.smcl setf smcl 2138 2139" Stored Procedures 2140au BufNewFile,BufRead *.stp setf stp 2141 2142" Standard ML 2143au BufNewFile,BufRead *.sml setf sml 2144 2145" Sratus VOS command macro 2146au BufNewFile,BufRead *.cm setf voscm 2147 2148" Sysctl 2149au BufNewFile,BufRead */etc/sysctl.conf,*/etc/sysctl.d/*.conf setf sysctl 2150 2151" Systemd unit files 2152au BufNewFile,BufRead */systemd/*.{automount,mount,path,service,socket,swap,target,timer} setf systemd 2153 2154" Synopsys Design Constraints 2155au BufNewFile,BufRead *.sdc setf sdc 2156 2157" Sudoers 2158au BufNewFile,BufRead */etc/sudoers,sudoers.tmp setf sudoers 2159 2160" SVG (Scalable Vector Graphics) 2161au BufNewFile,BufRead *.svg setf svg 2162 2163" If the file has an extension of 't' and is in a directory 't' or 'xt' then 2164" it is almost certainly a Perl test file. 2165" If the first line starts with '#' and contains 'perl' it's probably a Perl 2166" file. 2167" (Slow test) If a file contains a 'use' statement then it is almost certainly 2168" a Perl file. 2169func! s:FTperl() 2170 let dirname = expand("%:p:h:t") 2171 if expand("%:e") == 't' && (dirname == 't' || dirname == 'xt') 2172 setf perl 2173 return 1 2174 endif 2175 if getline(1)[0] == '#' && getline(1) =~ 'perl' 2176 setf perl 2177 return 1 2178 endif 2179 if search('^use\s\s*\k', 'nc', 30) 2180 setf perl 2181 return 1 2182 endif 2183 return 0 2184endfunc 2185 2186" Tads (or Nroff or Perl test file) 2187au BufNewFile,BufRead *.t 2188 \ if !s:FTnroff() && !s:FTperl() | setf tads | endif 2189 2190" Tags 2191au BufNewFile,BufRead tags setf tags 2192 2193" TAK 2194au BufNewFile,BufRead *.tak setf tak 2195 2196" Task 2197au BufRead,BufNewFile {pending,completed,undo}.data setf taskdata 2198au BufRead,BufNewFile *.task setf taskedit 2199 2200" Tcl (JACL too) 2201au BufNewFile,BufRead *.tcl,*.tk,*.itcl,*.itk,*.jacl setf tcl 2202 2203" TealInfo 2204au BufNewFile,BufRead *.tli setf tli 2205 2206" Telix Salt 2207au BufNewFile,BufRead *.slt setf tsalt 2208 2209" Tera Term Language 2210au BufRead,BufNewFile *.ttl setf teraterm 2211 2212" Terminfo 2213au BufNewFile,BufRead *.ti setf terminfo 2214 2215" TeX 2216au BufNewFile,BufRead *.latex,*.sty,*.dtx,*.ltx,*.bbl setf tex 2217au BufNewFile,BufRead *.tex call s:FTtex() 2218 2219" Choose context, plaintex, or tex (LaTeX) based on these rules: 2220" 1. Check the first line of the file for "%&<format>". 2221" 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords. 2222" 3. Default to "latex" or to g:tex_flavor, can be set in user's vimrc. 2223func! s:FTtex() 2224 let firstline = getline(1) 2225 if firstline =~ '^%&\s*\a\+' 2226 let format = tolower(matchstr(firstline, '\a\+')) 2227 let format = substitute(format, 'pdf', '', '') 2228 if format == 'tex' 2229 let format = 'plain' 2230 endif 2231 else 2232 " Default value, may be changed later: 2233 let format = exists("g:tex_flavor") ? g:tex_flavor : 'plain' 2234 " Save position, go to the top of the file, find first non-comment line. 2235 let save_cursor = getpos('.') 2236 call cursor(1,1) 2237 let firstNC = search('^\s*[^[:space:]%]', 'c', 1000) 2238 if firstNC " Check the next thousand lines for a LaTeX or ConTeXt keyword. 2239 let lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>' 2240 let cpat = '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\>' 2241 let kwline = search('^\s*\\\%(' . lpat . '\)\|^\s*\\\(' . cpat . '\)', 2242 \ 'cnp', firstNC + 1000) 2243 if kwline == 1 " lpat matched 2244 let format = 'latex' 2245 elseif kwline == 2 " cpat matched 2246 let format = 'context' 2247 endif " If neither matched, keep default set above. 2248 " let lline = search('^\s*\\\%(' . lpat . '\)', 'cn', firstNC + 1000) 2249 " let cline = search('^\s*\\\%(' . cpat . '\)', 'cn', firstNC + 1000) 2250 " if cline > 0 2251 " let format = 'context' 2252 " endif 2253 " if lline > 0 && (cline == 0 || cline > lline) 2254 " let format = 'tex' 2255 " endif 2256 endif " firstNC 2257 call setpos('.', save_cursor) 2258 endif " firstline =~ '^%&\s*\a\+' 2259 2260 " Translation from formats to file types. TODO: add AMSTeX, RevTex, others? 2261 if format == 'plain' 2262 setf plaintex 2263 elseif format == 'context' 2264 setf context 2265 else " probably LaTeX 2266 setf tex 2267 endif 2268 return 2269endfunc 2270 2271" ConTeXt 2272au BufNewFile,BufRead tex/context/*/*.tex,*.mkii,*.mkiv,*.mkvi setf context 2273 2274" Texinfo 2275au BufNewFile,BufRead *.texinfo,*.texi,*.txi setf texinfo 2276 2277" TeX configuration 2278au BufNewFile,BufRead texmf.cnf setf texmf 2279 2280" Tidy config 2281au BufNewFile,BufRead .tidyrc,tidyrc setf tidy 2282 2283" TF mud client 2284au BufNewFile,BufRead *.tf,.tfrc,tfrc setf tf 2285 2286" tmux configuration 2287au BufNewFile,BufRead {.,}tmux*.conf setf tmux 2288 2289" TPP - Text Presentation Program 2290au BufNewFile,BufReadPost *.tpp setf tpp 2291 2292" Treetop 2293au BufRead,BufNewFile *.treetop setf treetop 2294 2295" Trustees 2296au BufNewFile,BufRead trustees.conf setf trustees 2297 2298" TSS - Geometry 2299au BufNewFile,BufReadPost *.tssgm setf tssgm 2300 2301" TSS - Optics 2302au BufNewFile,BufReadPost *.tssop setf tssop 2303 2304" TSS - Command Line (temporary) 2305au BufNewFile,BufReadPost *.tsscl setf tsscl 2306 2307" TWIG files 2308au BufNewFile,BufReadPost *.twig setf twig 2309 2310" Motif UIT/UIL files 2311au BufNewFile,BufRead *.uit,*.uil setf uil 2312 2313" Udev conf 2314au BufNewFile,BufRead */etc/udev/udev.conf setf udevconf 2315 2316" Udev permissions 2317au BufNewFile,BufRead */etc/udev/permissions.d/*.permissions setf udevperm 2318" 2319" Udev symlinks config 2320au BufNewFile,BufRead */etc/udev/cdsymlinks.conf setf sh 2321 2322" UnrealScript 2323au BufNewFile,BufRead *.uc setf uc 2324 2325" Updatedb 2326au BufNewFile,BufRead */etc/updatedb.conf setf updatedb 2327 2328" Upstart (init(8)) config files 2329au BufNewFile,BufRead */usr/share/upstart/*.conf setf upstart 2330au BufNewFile,BufRead */usr/share/upstart/*.override setf upstart 2331au BufNewFile,BufRead */etc/init/*.conf,*/etc/init/*.override setf upstart 2332au BufNewFile,BufRead */.init/*.conf,*/.init/*.override setf upstart 2333au BufNewFile,BufRead */.config/upstart/*.conf setf upstart 2334au BufNewFile,BufRead */.config/upstart/*.override setf upstart 2335 2336" Vera 2337au BufNewFile,BufRead *.vr,*.vri,*.vrh setf vera 2338 2339" Verilog HDL 2340au BufNewFile,BufRead *.v setf verilog 2341 2342" Verilog-AMS HDL 2343au BufNewFile,BufRead *.va,*.vams setf verilogams 2344 2345" SystemVerilog 2346au BufNewFile,BufRead *.sv,*.svh setf systemverilog 2347 2348" VHDL 2349au BufNewFile,BufRead *.hdl,*.vhd,*.vhdl,*.vbe,*.vst setf vhdl 2350au BufNewFile,BufRead *.vhdl_[0-9]* call s:StarSetf('vhdl') 2351 2352" Vim script 2353au BufNewFile,BufRead *.vim,*.vba,.exrc,_exrc setf vim 2354 2355" Viminfo file 2356au BufNewFile,BufRead .viminfo,_viminfo setf viminfo 2357 2358" Virata Config Script File or Drupal module 2359au BufRead,BufNewFile *.hw,*.module,*.pkg 2360 \ if getline(1) =~ '<?php' | 2361 \ setf php | 2362 \ else | 2363 \ setf virata | 2364 \ endif 2365 2366" Visual Basic (also uses *.bas) or FORM 2367au BufNewFile,BufRead *.frm call s:FTVB("form") 2368 2369" SaxBasic is close to Visual Basic 2370au BufNewFile,BufRead *.sba setf vb 2371 2372" Vgrindefs file 2373au BufNewFile,BufRead vgrindefs setf vgrindefs 2374 2375" VRML V1.0c 2376au BufNewFile,BufRead *.wrl setf vrml 2377 2378" Vroom (vim testing and executable documentation) 2379au BufNewFile,BufRead *.vroom setf vroom 2380 2381" Webmacro 2382au BufNewFile,BufRead *.wm setf webmacro 2383 2384" Wget config 2385au BufNewFile,BufRead .wgetrc,wgetrc setf wget 2386 2387" Website MetaLanguage 2388au BufNewFile,BufRead *.wml setf wml 2389 2390" Winbatch 2391au BufNewFile,BufRead *.wbt setf winbatch 2392 2393" WSML 2394au BufNewFile,BufRead *.wsml setf wsml 2395 2396" WvDial 2397au BufNewFile,BufRead wvdial.conf,.wvdialrc setf wvdial 2398 2399" CVS RC file 2400au BufNewFile,BufRead .cvsrc setf cvsrc 2401 2402" CVS commit file 2403au BufNewFile,BufRead cvs\d\+ setf cvs 2404 2405" WEB (*.web is also used for Winbatch: Guess, based on expecting "%" comment 2406" lines in a WEB file). 2407au BufNewFile,BufRead *.web 2408 \ if getline(1)[0].getline(2)[0].getline(3)[0].getline(4)[0].getline(5)[0] =~ "%" | 2409 \ setf web | 2410 \ else | 2411 \ setf winbatch | 2412 \ endif 2413 2414" Windows Scripting Host and Windows Script Component 2415au BufNewFile,BufRead *.ws[fc] setf wsh 2416 2417" XHTML 2418au BufNewFile,BufRead *.xhtml,*.xht setf xhtml 2419 2420" X Pixmap (dynamically sets colors, use BufEnter to make it work better) 2421au BufEnter *.xpm 2422 \ if getline(1) =~ "XPM2" | 2423 \ setf xpm2 | 2424 \ else | 2425 \ setf xpm | 2426 \ endif 2427au BufEnter *.xpm2 setf xpm2 2428 2429" XFree86 config 2430au BufNewFile,BufRead XF86Config 2431 \ if getline(1) =~ '\<XConfigurator\>' | 2432 \ let b:xf86conf_xfree86_version = 3 | 2433 \ endif | 2434 \ setf xf86conf 2435au BufNewFile,BufRead */xorg.conf.d/*.conf 2436 \ let b:xf86conf_xfree86_version = 4 | 2437 \ setf xf86conf 2438 2439" Xorg config 2440au BufNewFile,BufRead xorg.conf,xorg.conf-4 let b:xf86conf_xfree86_version = 4 | setf xf86conf 2441 2442" Xinetd conf 2443au BufNewFile,BufRead */etc/xinetd.conf setf xinetd 2444 2445" XS Perl extension interface language 2446au BufNewFile,BufRead *.xs setf xs 2447 2448" X resources file 2449au BufNewFile,BufRead .Xdefaults,.Xpdefaults,.Xresources,xdm-config,*.ad setf xdefaults 2450 2451" Xmath 2452au BufNewFile,BufRead *.msc,*.msf setf xmath 2453au BufNewFile,BufRead *.ms 2454 \ if !s:FTnroff() | setf xmath | endif 2455 2456" XML specific variants: docbk and xbl 2457au BufNewFile,BufRead *.xml call s:FTxml() 2458 2459func! s:FTxml() 2460 let n = 1 2461 while n < 100 && n < line("$") 2462 let line = getline(n) 2463 " DocBook 4 or DocBook 5. 2464 let is_docbook4 = line =~ '<!DOCTYPE.*DocBook' 2465 let is_docbook5 = line =~ ' xmlns="http://docbook.org/ns/docbook"' 2466 if is_docbook4 || is_docbook5 2467 let b:docbk_type = "xml" 2468 if is_docbook5 2469 let b:docbk_ver = 5 2470 else 2471 let b:docbk_ver = 4 2472 endif 2473 setf docbk 2474 return 2475 endif 2476 if line =~ 'xmlns:xbl="http://www.mozilla.org/xbl"' 2477 setf xbl 2478 return 2479 endif 2480 let n += 1 2481 endwhile 2482 setf xml 2483endfunc 2484 2485" XMI (holding UML models) is also XML 2486au BufNewFile,BufRead *.xmi setf xml 2487 2488" CSPROJ files are Visual Studio.NET's XML-based project config files 2489au BufNewFile,BufRead *.csproj,*.csproj.user setf xml 2490 2491" Qt Linguist translation source and Qt User Interface Files are XML 2492au BufNewFile,BufRead *.ts,*.ui setf xml 2493 2494" TPM's are RDF-based descriptions of TeX packages (Nikolai Weibull) 2495au BufNewFile,BufRead *.tpm setf xml 2496 2497" Xdg menus 2498au BufNewFile,BufRead */etc/xdg/menus/*.menu setf xml 2499 2500" ATI graphics driver configuration 2501au BufNewFile,BufRead fglrxrc setf xml 2502 2503" XLIFF (XML Localisation Interchange File Format) is also XML 2504au BufNewFile,BufRead *.xlf setf xml 2505au BufNewFile,BufRead *.xliff setf xml 2506 2507" XML User Interface Language 2508au BufNewFile,BufRead *.xul setf xml 2509 2510" X11 xmodmap (also see below) 2511au BufNewFile,BufRead *Xmodmap setf xmodmap 2512 2513" Xquery 2514au BufNewFile,BufRead *.xq,*.xql,*.xqm,*.xquery,*.xqy setf xquery 2515 2516" XSD 2517au BufNewFile,BufRead *.xsd setf xsd 2518 2519" Xslt 2520au BufNewFile,BufRead *.xsl,*.xslt setf xslt 2521 2522" Yacc 2523au BufNewFile,BufRead *.yy,*.yxx,*.y++ setf yacc 2524 2525" Yacc or racc 2526au BufNewFile,BufRead *.y call s:FTy() 2527 2528func! s:FTy() 2529 let n = 1 2530 while n < 100 && n < line("$") 2531 let line = getline(n) 2532 if line =~ '^\s*%' 2533 setf yacc 2534 return 2535 endif 2536 if getline(n) =~ '^\s*\(#\|class\>\)' && getline(n) !~ '^\s*#\s*include' 2537 setf racc 2538 return 2539 endif 2540 let n = n + 1 2541 endwhile 2542 setf yacc 2543endfunc 2544 2545 2546" Yaml 2547au BufNewFile,BufRead *.yaml,*.yml setf yaml 2548 2549" yum conf (close enough to dosini) 2550au BufNewFile,BufRead */etc/yum.conf setf dosini 2551 2552" Zimbu 2553au BufNewFile,BufRead *.zu setf zimbu 2554" Zimbu Templates 2555au BufNewFile,BufRead *.zut setf zimbutempl 2556 2557" Zope 2558" dtml (zope dynamic template markup language), pt (zope page template), 2559" cpt (zope form controller page template) 2560au BufNewFile,BufRead *.dtml,*.pt,*.cpt call s:FThtml() 2561" zsql (zope sql method) 2562au BufNewFile,BufRead *.zsql call s:SQL() 2563 2564" Z80 assembler asz80 2565au BufNewFile,BufRead *.z8a setf z8a 2566 2567augroup END 2568 2569 2570" Source the user-specified filetype file, for backwards compatibility with 2571" Vim 5.x. 2572if exists("myfiletypefile") && filereadable(expand(myfiletypefile)) 2573 execute "source " . myfiletypefile 2574endif 2575 2576 2577" Check for "*" after loading myfiletypefile, so that scripts.vim is only used 2578" when there are no matching file name extensions. 2579" Don't do this for compressed files. 2580augroup filetypedetect 2581au BufNewFile,BufRead * 2582 \ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat 2583 \ | runtime! scripts.vim | endif 2584au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif 2585 2586 2587" Extra checks for when no filetype has been detected now. Mostly used for 2588" patterns that end in "*". E.g., "zsh*" matches "zsh.vim", but that's a Vim 2589" script file. 2590" Most of these should call s:StarSetf() to avoid names ending in .gz and the 2591" like are used. 2592 2593" More Apache config files 2594au BufNewFile,BufRead access.conf*,apache.conf*,apache2.conf*,httpd.conf*,srm.conf* call s:StarSetf('apache') 2595au BufNewFile,BufRead */etc/apache2/*.conf*,*/etc/apache2/conf.*/*,*/etc/apache2/mods-*/*,*/etc/apache2/sites-*/*,*/etc/httpd/conf.d/*.conf* call s:StarSetf('apache') 2596 2597" Asterisk config file 2598au BufNewFile,BufRead *asterisk/*.conf* call s:StarSetf('asterisk') 2599au BufNewFile,BufRead *asterisk*/*voicemail.conf* call s:StarSetf('asteriskvm') 2600 2601" Bazaar version control 2602au BufNewFile,BufRead bzr_log.* setf bzr 2603 2604" BIND zone 2605au BufNewFile,BufRead */named/db.*,*/bind/db.* call s:StarSetf('bindzone') 2606 2607" Calendar 2608au BufNewFile,BufRead */.calendar/*, 2609 \*/share/calendar/*/calendar.*,*/share/calendar/calendar.* 2610 \ call s:StarSetf('calendar') 2611 2612" Changelog 2613au BufNewFile,BufRead [cC]hange[lL]og* 2614 \ if getline(1) =~ '; urgency=' 2615 \| call s:StarSetf('debchangelog') 2616 \|else 2617 \| call s:StarSetf('changelog') 2618 \|endif 2619 2620" Crontab 2621au BufNewFile,BufRead crontab,crontab.*,*/etc/cron.d/* call s:StarSetf('crontab') 2622 2623" dnsmasq(8) configuration 2624au BufNewFile,BufRead */etc/dnsmasq.d/* call s:StarSetf('dnsmasq') 2625 2626" Dracula 2627au BufNewFile,BufRead drac.* call s:StarSetf('dracula') 2628 2629" Fvwm 2630au BufNewFile,BufRead */.fvwm/* call s:StarSetf('fvwm') 2631au BufNewFile,BufRead *fvwmrc*,*fvwm95*.hook 2632 \ let b:fvwm_version = 1 | call s:StarSetf('fvwm') 2633au BufNewFile,BufRead *fvwm2rc* 2634 \ if expand("<afile>:e") == "m4" 2635 \| call s:StarSetf('fvwm2m4') 2636 \|else 2637 \| let b:fvwm_version = 2 | call s:StarSetf('fvwm') 2638 \|endif 2639 2640" Gedcom 2641au BufNewFile,BufRead */tmp/lltmp* call s:StarSetf('gedcom') 2642 2643" GTK RC 2644au BufNewFile,BufRead .gtkrc*,gtkrc* call s:StarSetf('gtkrc') 2645 2646" Jam 2647au BufNewFile,BufRead Prl*.*,JAM*.* call s:StarSetf('jam') 2648 2649" Jargon 2650au! BufNewFile,BufRead *jarg* 2651 \ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'THIS IS THE JARGON FILE' 2652 \| call s:StarSetf('jargon') 2653 \|endif 2654 2655" Kconfig 2656au BufNewFile,BufRead Kconfig.* call s:StarSetf('kconfig') 2657 2658" Lilo: Linux loader 2659au BufNewFile,BufRead lilo.conf* call s:StarSetf('lilo') 2660 2661" Logcheck 2662au BufNewFile,BufRead */etc/logcheck/*.d*/* call s:StarSetf('logcheck') 2663 2664" Makefile 2665au BufNewFile,BufRead [mM]akefile* call s:StarSetf('make') 2666 2667" Ruby Makefile 2668au BufNewFile,BufRead [rR]akefile* call s:StarSetf('ruby') 2669 2670" Mail (also matches muttrc.vim, so this is below the other checks) 2671au BufNewFile,BufRead mutt[[:alnum:]._-]\\\{6\} setf mail 2672 2673au BufNewFile,BufRead reportbug-* call s:StarSetf('mail') 2674 2675" Modconf 2676au BufNewFile,BufRead */etc/modutils/* 2677 \ if executable(expand("<afile>")) != 1 2678 \| call s:StarSetf('modconf') 2679 \|endif 2680au BufNewFile,BufRead */etc/modprobe.* call s:StarSetf('modconf') 2681 2682" Mutt setup file 2683au BufNewFile,BufRead .mutt{ng,}rc*,*/.mutt{ng,}/mutt{ng,}rc* call s:StarSetf('muttrc') 2684au BufNewFile,BufRead mutt{ng,}rc*,Mutt{ng,}rc* call s:StarSetf('muttrc') 2685 2686" Nroff macros 2687au BufNewFile,BufRead tmac.* call s:StarSetf('nroff') 2688 2689" OpenBSD hostname.if 2690au BufNewFile,BufRead /etc/hostname.* call s:StarSetf('config') 2691 2692" Pam conf 2693au BufNewFile,BufRead */etc/pam.d/* call s:StarSetf('pamconf') 2694 2695" Printcap and Termcap 2696au BufNewFile,BufRead *printcap* 2697 \ if !did_filetype() 2698 \| let b:ptcap_type = "print" | call s:StarSetf('ptcap') 2699 \|endif 2700au BufNewFile,BufRead *termcap* 2701 \ if !did_filetype() 2702 \| let b:ptcap_type = "term" | call s:StarSetf('ptcap') 2703 \|endif 2704 2705" ReDIF 2706" Only used when the .rdf file was not detected to be XML. 2707au BufRead,BufNewFile *.rdf call s:Redif() 2708func! s:Redif() 2709 let lnum = 1 2710 while lnum <= 5 && lnum < line('$') 2711 if getline(lnum) =~ "^\ctemplate-type:" 2712 setf redif 2713 return 2714 endif 2715 let lnum = lnum + 1 2716 endwhile 2717endfunc 2718 2719" Remind 2720au BufNewFile,BufRead .reminders* call s:StarSetf('remind') 2721 2722" Vim script 2723au BufNewFile,BufRead *vimrc* call s:StarSetf('vim') 2724 2725" Subversion commit file 2726au BufNewFile,BufRead svn-commit*.tmp setf svn 2727 2728" X resources file 2729au BufNewFile,BufRead Xresources*,*/app-defaults/*,*/Xresources/* call s:StarSetf('xdefaults') 2730 2731" XFree86 config 2732au BufNewFile,BufRead XF86Config-4* 2733 \ let b:xf86conf_xfree86_version = 4 | call s:StarSetf('xf86conf') 2734au BufNewFile,BufRead XF86Config* 2735 \ if getline(1) =~ '\<XConfigurator\>' 2736 \| let b:xf86conf_xfree86_version = 3 2737 \|endif 2738 \|call s:StarSetf('xf86conf') 2739 2740" X11 xmodmap 2741au BufNewFile,BufRead *xmodmap* call s:StarSetf('xmodmap') 2742 2743" Xinetd conf 2744au BufNewFile,BufRead */etc/xinetd.d/* call s:StarSetf('xinetd') 2745 2746" yum conf (close enough to dosini) 2747au BufNewFile,BufRead */etc/yum.repos.d/* call s:StarSetf('dosini') 2748 2749" Z-Shell script 2750au BufNewFile,BufRead zsh*,zlog* call s:StarSetf('zsh') 2751 2752 2753" Plain text files, needs to be far down to not override others. This avoids 2754" the "conf" type being used if there is a line starting with '#'. 2755au BufNewFile,BufRead *.txt,*.text,README setf text 2756 2757 2758" Use the filetype detect plugins. They may overrule any of the previously 2759" detected filetypes. 2760runtime! ftdetect/*.vim 2761 2762" NOTE: The above command could have ended the filetypedetect autocmd group 2763" and started another one. Let's make sure it has ended to get to a consistent 2764" state. 2765augroup END 2766 2767" Generic configuration file (check this last, it's just guessing!) 2768au filetypedetect BufNewFile,BufRead,StdinReadPost * 2769 \ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat 2770 \ && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#' 2771 \ || getline(4) =~ '^#' || getline(5) =~ '^#') | 2772 \ setf conf | 2773 \ endif 2774 2775 2776" If the GUI is already running, may still need to install the Syntax menu. 2777" Don't do it when the 'M' flag is included in 'guioptions'. 2778if has("menu") && has("gui_running") 2779 \ && !exists("did_install_syntax_menu") && &guioptions !~# "M" 2780 source <sfile>:p:h/menu.vim 2781endif 2782 2783" Function called for testing all functions defined here. These are 2784" script-local, thus need to be executed here. 2785" Returns a string with error messages (hopefully empty). 2786func! TestFiletypeFuncs(testlist) 2787 let output = '' 2788 for f in a:testlist 2789 try 2790 exe f 2791 catch 2792 let output = output . "\n" . f . ": " . v:exception 2793 endtry 2794 endfor 2795 return output 2796endfunc 2797 2798" Restore 'cpoptions' 2799let &cpo = s:cpo_save 2800unlet s:cpo_save 2801