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