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