Runtime files update
[MacVim.git] / runtime / filetype.vim
blob5fa84b678a761baef61d161625d1b464513c5177
1 " Vim support file to detect file types
3 " Maintainer:   Bram Moolenaar <Bram@vim.org>
4 " Last Change:  2008 Feb 06
6 " Listen very carefully, I will say this only once
7 if exists("did_load_filetypes")
8   finish
9 endif
10 let did_load_filetypes = 1
12 " Line continuation is used here, remove 'C' from 'cpoptions'
13 let s:cpo_save = &cpo
14 set cpo&vim
16 augroup filetypedetect
18 " Ignored extensions
19 au BufNewFile,BufRead ?\+.orig,?\+.bak,?\+.old,?\+.new,?\+.rpmsave,?\+.rpmnew
20         \ exe "doau filetypedetect BufRead " . expand("<afile>:r")
21 au BufNewFile,BufRead *~
22         \ let s:name = expand("<afile>") |
23         \ let s:short = substitute(s:name, '\~$', '', '') |
24         \ if s:name != s:short && s:short != "" |
25         \   exe "doau filetypedetect BufRead " . s:short |
26         \ endif |
27         \ unlet s:name |
28         \ unlet s:short
29 au BufNewFile,BufRead ?\+.in
30         \ if expand("<afile>:t") != "configure.in" |
31         \   exe "doau filetypedetect BufRead " . expand("<afile>:r") |
32         \ endif
34 " Pattern used to match file names which should not be inspected.
35 " Currently finds compressed files.
36 if !exists("g:ft_ignore_pat")
37   let g:ft_ignore_pat = '\.\(Z\|gz\|bz2\|zip\|tgz\)$'
38 endif
40 " Function used for patterns that end in a star: don't set the filetype if the
41 " file name matches ft_ignore_pat.
42 func! s:StarSetf(ft)
43   if expand("<amatch>") !~ g:ft_ignore_pat
44     exe 'setf ' . a:ft
45   endif
46 endfunc
48 " Abaqus or Trasys
49 au BufNewFile,BufRead *.inp                     call s:Check_inp()
51 func! s:Check_inp()
52   if getline(1) =~ '^\*'
53     setf abaqus
54   else
55     let n = 1
56     if line("$") > 500
57       let nmax = 500
58     else
59       let nmax = line("$")
60     endif
61     while n <= nmax
62       if getline(n) =~? "^header surface data"
63         setf trasys
64         break
65       endif
66       let n = n + 1
67     endwhile
68   endif
69 endfunc
71 " A-A-P recipe
72 au BufNewFile,BufRead *.aap                     setf aap
74 " A2ps printing utility
75 au BufNewFile,BufRead etc/a2ps.cfg,etc/a2ps/*.cfg,a2psrc,.a2psrc setf a2ps
77 " ABAB/4
78 au BufNewFile,BufRead *.abap                    setf abap
80 " ABC music notation
81 au BufNewFile,BufRead *.abc                     setf abc
83 " ABEL
84 au BufNewFile,BufRead *.abl                     setf abel
86 " AceDB
87 au BufNewFile,BufRead *.wrm                     setf acedb
89 " Ada (83, 9X, 95)
90 au BufNewFile,BufRead *.adb,*.ads,*.ada         setf ada
91 if has("vms")
92   au BufNewFile,BufRead *.gpr,*.ada_m,*.adc     setf ada
93 else
94   au BufNewFile,BufRead *.gpr                   setf ada
95 endif
97 " AHDL
98 au BufNewFile,BufRead *.tdf                     setf ahdl
100 " AMPL
101 au BufNewFile,BufRead *.run                     setf ampl
103 " Ant
104 au BufNewFile,BufRead build.xml                 setf ant
106 " Apache style config file
107 au BufNewFile,BufRead proftpd.conf*             call s:StarSetf('apachestyle')
109 " Apache config file
110 au BufNewFile,BufRead .htaccess                  setf apache
111 au BufNewFile,BufRead httpd.conf*,srm.conf*,access.conf*,apache.conf*,apache2.conf*,/etc/apache2/*.conf* call s:StarSetf('apache')
113 " XA65 MOS6510 cross assembler
114 au BufNewFile,BufRead *.a65                     setf a65
116 " Applix ELF
117 au BufNewFile,BufRead *.am
118         \ if expand("<afile>") !~? 'Makefile.am\>' | setf elf | endif
120 " ALSA configuration
121 au BufNewFile,BufRead ~/.asoundrc,/usr/share/alsa/alsa.conf,/etc/asound.conf    setf alsaconf
123 " Arc Macro Language
124 au BufNewFile,BufRead *.aml                     setf aml
126 " Arch Inventory file
127 au BufNewFile,BufRead .arch-inventory,=tagging-method   setf arch
129 " ART*Enterprise (formerly ART-IM)
130 au BufNewFile,BufRead *.art                     setf art
132 " ASN.1
133 au BufNewFile,BufRead *.asn,*.asn1              setf asn
135 " Active Server Pages (with Visual Basic Script)
136 au BufNewFile,BufRead *.asa
137         \ if exists("g:filetype_asa") |
138         \   exe "setf " . g:filetype_asa |
139         \ else |
140         \   setf aspvbs |
141         \ endif
143 " Active Server Pages (with Perl or Visual Basic Script)
144 au BufNewFile,BufRead *.asp
145         \ if exists("g:filetype_asp") |
146         \   exe "setf " . g:filetype_asp |
147         \ elseif getline(1) . getline(2) . getline(3) =~? "perlscript" |
148         \   setf aspperl |
149         \ else |
150         \   setf aspvbs |
151         \ endif
153 " Grub (must be before catch *.lst)
154 au BufNewFile,BufRead /boot/grub/menu.lst,/boot/grub/grub.conf,/etc/grub.conf   setf grub
156 " Assembly (all kinds)
157 " *.lst is not pure assembly, it has two extra columns (address, byte codes)
158 au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst   call s:FTasm()
160 " This function checks for the kind of assembly that is wanted by the user, or
161 " can be detected from the first five lines of the file.
162 func! s:FTasm()
163   " make sure b:asmsyntax exists
164   if !exists("b:asmsyntax")
165     let b:asmsyntax = ""
166   endif
168   if b:asmsyntax == ""
169     call s:FTasmsyntax()
170   endif
172   " if b:asmsyntax still isn't set, default to asmsyntax or GNU
173   if b:asmsyntax == ""
174     if exists("g:asmsyntax")
175       let b:asmsyntax = g:asmsyntax
176     else
177       let b:asmsyntax = "asm"
178     endif
179   endif
181   exe "setf " . b:asmsyntax
182 endfunc
184 func! s:FTasmsyntax()
185   " see if file contains any asmsyntax=foo overrides. If so, change
186   " b:asmsyntax appropriately
187   let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4).
188         \" ".getline(5)." "
189   if head =~ '\sasmsyntax=\S\+\s'
190     let b:asmsyntax = substitute(head, '.*\sasmsyntax=\(\S\+\)\s.*','\1', "")
191   elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library'))
192     let b:asmsyntax = "vmasm"
193   endif
194 endfunc
196 " Macro (VAX)
197 au BufNewFile,BufRead *.mar                     setf vmasm
199 " Atlas
200 au BufNewFile,BufRead *.atl,*.as                setf atlas
202 " Autoit v3
203 au BufNewFile,BufRead *.au3                     setf autoit
205 " Autohotkey
206 au BufNewFile,BufRead *.ahk                     setf autohotkey
208 " Automake
209 au BufNewFile,BufRead [mM]akefile.am,GNUmakefile.am     setf automake
211 " Autotest .at files are actually m4
212 au BufNewFile,BufRead *.at                      setf m4
214 " Avenue
215 au BufNewFile,BufRead *.ave                     setf ave
217 " Awk
218 au BufNewFile,BufRead *.awk                     setf awk
220 " B
221 au BufNewFile,BufRead *.mch,*.ref,*.imp         setf b
223 " BASIC or Visual Basic
224 au BufNewFile,BufRead *.bas                     call s:FTVB("basic")
226 " Check if one of the first five lines contains "VB_Name".  In that case it is
227 " probably a Visual Basic file.  Otherwise it's assumed to be "alt" filetype.
228 func! s:FTVB(alt)
229   if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)'
230     setf vb
231   else
232     exe "setf " . a:alt
233   endif
234 endfunc
236 " Visual Basic Script (close to Visual Basic)
237 au BufNewFile,BufRead *.vbs,*.dsm,*.ctl         setf vb
239 " IBasic file (similar to QBasic)
240 au BufNewFile,BufRead *.iba,*.ibi               setf ibasic
242 " FreeBasic file (similar to QBasic)
243 au BufNewFile,BufRead *.fb,*.bi                 setf freebasic
245 " Batch file for MSDOS.
246 au BufNewFile,BufRead *.bat,*.sys               setf dosbatch
247 " *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd.
248 au BufNewFile,BufRead *.cmd
249         \ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif
251 " Batch file for 4DOS
252 au BufNewFile,BufRead *.btm                     call s:FTbtm()
253 func! s:FTbtm()
254   if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm
255     setf dosbatch
256   else
257     setf btm
258   endif
259 endfunc
261 " BC calculator
262 au BufNewFile,BufRead *.bc                      setf bc
264 " BDF font
265 au BufNewFile,BufRead *.bdf                     setf bdf
267 " BibTeX bibliography database file
268 au BufNewFile,BufRead *.bib                     setf bib
270 " BibTeX Bibliography Style
271 au BufNewFile,BufRead *.bst                     setf bst
273 " BIND configuration
274 au BufNewFile,BufRead named.conf,rndc.conf      setf named
276 " BIND zone
277 au BufNewFile,BufRead named.root                setf bindzone
278 au BufNewFile,BufRead *.db                      call s:BindzoneCheck('')
280 func! s:BindzoneCheck(default)
281   if getline(1).getline(2).getline(3).getline(4) =~ '^; <<>> DiG [0-9.]\+ <<>>\|BIND.*named\|$ORIGIN\|$TTL\|IN\s\+SOA'
282     setf bindzone
283   elseif a:default != ''
284     exe 'setf ' . a:default
285   endif
286 endfunc
288 " Blank
289 au BufNewFile,BufRead *.bl                      setf blank
291 " C or lpc
292 au BufNewFile,BufRead *.c                       call s:FTlpc()
294 func! s:FTlpc()
295   if exists("g:lpc_syntax_for_c")
296     let lnum = 1
297     while lnum <= 12
298       if getline(lnum) =~# '^\(//\|inherit\|private\|protected\|nosave\|string\|object\|mapping\|mixed\)'
299         setf lpc
300         return
301       endif
302       let lnum = lnum + 1
303     endwhile
304   endif
305   setf c
306 endfunc
308 " Calendar
309 au BufNewFile,BufRead calendar                  setf calendar
310 au BufNewFile,BufRead */.calendar/*,
311         \*/share/calendar/*/calendar.*,*/share/calendar/calendar.*
312         \                                       call s:StarSetf('calendar')
314 " C#
315 au BufNewFile,BufRead *.cs                      setf cs
317 " Cdrdao TOC
318 au BufNewFile,BufRead *.toc                     setf cdrtoc
320 " Cdrdao config
321 au BufNewFile,BufRead etc/cdrdao.conf,etc/defaults/cdrdao,etc/default/cdrdao,~/.cdrdao                                          setf cdrdaoconf
323 " Cfengine
324 au BufNewFile,BufRead cfengine.conf             setf cfengine
326 " Comshare Dimension Definition Language
327 au BufNewFile,BufRead *.cdl                     setf cdl
329 " Conary Recipe
330 au BufNewFile,BufRead *.recipe                  setf conaryrecipe
332 " Controllable Regex Mutilator
333 au BufNewFile,BufRead *.crm                     setf crm
335 " Cyn++
336 au BufNewFile,BufRead *.cyn                     setf cynpp
338 " Cynlib
339 " .cc and .cpp files can be C++ or Cynlib.
340 au BufNewFile,BufRead *.cc
341         \ if exists("cynlib_syntax_for_cc")|setf cynlib|else|setf cpp|endif
342 au BufNewFile,BufRead *.cpp
343         \ if exists("cynlib_syntax_for_cpp")|setf cynlib|else|setf cpp|endif
345 " C++
346 if has("fname_case")
347   au BufNewFile,BufRead *.cxx,*.c++,*.C,*.H,*.hh,*.hxx,*.hpp,*.moc,*.tcc,*.inl setf cpp
348 else
349   au BufNewFile,BufRead *.cxx,*.c++,*.hh,*.hxx,*.hpp,*.moc,*.tcc,*.inl setf cpp
350 endif
352 " .h files can be C, Ch C++, ObjC or ObjC++.
353 " Set c_syntax_for_h if you want C, ch_syntax_for_h if you want Ch. ObjC is
354 " detected automatically.
355 au BufNewFile,BufRead *.h                       call s:FTheader()
357 func! s:FTheader()
358   if match(getline(1, min([line("$"), 200])), '^@\(interface\|end\|class\)') > -1
359     setf objc
360   elseif exists("c_syntax_for_h")
361     setf c
362   elseif exists("ch_syntax_for_h")
363     setf ch
364   else
365     setf cpp
366   endif
367 endfunc
369 " Ch (CHscript)
370 au BufNewFile,BufRead *.chf                     setf ch
372 " TLH files are C++ headers generated by Visual C++'s #import from typelibs
373 au BufNewFile,BufRead *.tlh                     setf cpp
375 " Cascading Style Sheets
376 au BufNewFile,BufRead *.css                     setf css
378 " Century Term Command Scripts (*.cmd too)
379 au BufNewFile,BufRead *.con                     setf cterm
381 " Changelog
382 au BufNewFile,BufRead changelog.Debian,changelog.dch,NEWS.Debian,NEWS.dch
383                                         \       setf debchangelog
385 au BufNewFile,BufRead [cC]hange[lL]og
386         \  if getline(1) =~ '; urgency='
387         \|   setf debchangelog
388         \| else
389         \|   setf changelog
390         \| endif
392 au BufNewFile,BufRead NEWS
393         \  if getline(1) =~ '; urgency='
394         \|   setf debchangelog
395         \| endif
397 " CHILL
398 au BufNewFile,BufRead *..ch                     setf chill
400 " Changes for WEB and CWEB or CHILL
401 au BufNewFile,BufRead *.ch                      call s:FTchange()
403 " This function checks if one of the first ten lines start with a '@'.  In
404 " that case it is probably a change file.
405 " If the first line starts with # or ! it's probably a ch file.
406 " If a line has "main", "include", "//" ir "/*" it's probably ch.
407 " Otherwise CHILL is assumed.
408 func! s:FTchange()
409   let lnum = 1
410   while lnum <= 10
411     if getline(lnum)[0] == '@'
412       setf change
413       return
414     endif
415     if lnum == 1 && (getline(1)[0] == '#' || getline(1)[0] == '!')
416       setf ch
417       return
418     endif
419     if getline(lnum) =~ "MODULE"
420       setf chill
421       return
422     endif
423     if getline(lnum) =~ 'main\s*(\|#\s*include\|//'
424       setf ch
425       return
426     endif
427     let lnum = lnum + 1
428   endwhile
429   setf chill
430 endfunc
432 " ChordPro
433 au BufNewFile,BufRead *.chopro,*.crd,*.cho,*.crdpro,*.chordpro  setf chordpro
435 " Clean
436 au BufNewFile,BufRead *.dcl,*.icl               setf clean
438 " Clever
439 au BufNewFile,BufRead *.eni                     setf cl
441 " Clever or dtd
442 au BufNewFile,BufRead *.ent                     call s:FTent()
444 func! s:FTent()
445   " This function checks for valid cl syntax in the first five lines.
446   " Look for either an opening comment, '#', or a block start, '{".
447   " If not found, assume SGML.
448   let lnum = 1
449   while lnum < 6
450     let line = getline(lnum)
451     if line =~ '^\s*[#{]'
452       setf cl
453       return
454     elseif line !~ '^\s*$'
455       " Not a blank line, not a comment, and not a block start,
456       " so doesn't look like valid cl code.
457       break
458     endif
459     let lnum = lnum + 1
460   endw
461   setf dtd
462 endfunc
464 " Clipper (or FoxPro; could also be eviews)
465 au BufNewFile,BufRead *.prg
466         \ if exists("g:filetype_prg") |
467         \   exe "setf " . g:filetype_prg |
468         \ else |
469         \   setf clipper |
470         \ endif
472 " Cmake
473 au BufNewFile,BufRead CMakeLists.txt,*.cmake,*.cmake.in         setf cmake
475 " Cmusrc
476 au BufNewFile,BufRead ~/.cmus/{autosave,rc,command-history,*.theme} setf cmusrc
477 au BufNewFile,BufRead */cmus/{rc,*.theme}                       setf cmusrc
479 " Cobol
480 au BufNewFile,BufRead *.cbl,*.cob,*.lib setf cobol
481 "   cobol or zope form controller python script? (heuristic)
482 au BufNewFile,BufRead *.cpy
483         \ if getline(1) =~ '^##' |
484         \   setf python |
485         \ else |
486         \   setf cobol |
487         \ endif
489 " Coco/R
490 au BufNewFile,BufRead *.atg                     setf coco
492 " Cold Fusion
493 au BufNewFile,BufRead *.cfm,*.cfi,*.cfc         setf cf
495 " Configure scripts
496 au BufNewFile,BufRead configure.in,configure.ac setf config
498 " CUDA  Cumpute Unified Device Architecture
499 au BufNewFile,BufRead *.cu                      setf cuda
501 " WildPackets EtherPeek Decoder
502 au BufNewFile,BufRead *.dcd                     setf dcd
504 " Enlightenment configuration files
505 au BufNewFile,BufRead *enlightenment/*.cfg      setf c
507 " Eterm
508 au BufNewFile,BufRead *Eterm/*.cfg              setf eterm
510 " Lynx config files
511 au BufNewFile,BufRead lynx.cfg                  setf lynx
513 " Quake
514 au BufNewFile,BufRead *baseq[2-3]/*.cfg,*id1/*.cfg      setf quake
515 au BufNewFile,BufRead *quake[1-3]/*.cfg                 setf quake
517 " Quake C
518 au BufNewFile,BufRead *.qc                      setf c
520 " Configure files
521 au BufNewFile,BufRead *.cfg                     setf cfg
523 " Communicating Sequential Processes
524 au BufNewFile,BufRead *.csp,*.fdr               setf csp
526 " CUPL logic description and simulation
527 au BufNewFile,BufRead *.pld                     setf cupl
528 au BufNewFile,BufRead *.si                      setf cuplsim
530 " Debian Control
531 au BufNewFile,BufRead */debian/control          setf debcontrol
533 " Debian Sources.list
534 au BufNewFile,BufRead /etc/apt/sources.list     setf debsources
536 " Deny hosts
537 au BufNewFile,BufRead denyhosts.conf            setf denyhosts
539 " ROCKLinux package description
540 au BufNewFile,BufRead *.desc                    setf desc
542 " the D language
543 au BufNewFile,BufRead *.d                       setf d
545 " Desktop files
546 au BufNewFile,BufRead *.desktop,.directory      setf desktop
548 " Dict config
549 au BufNewFile,BufRead dict.conf,.dictrc         setf dictconf
551 " Dictd config
552 au BufNewFile,BufRead dictd.conf                setf dictdconf
554 " Diff files
555 au BufNewFile,BufRead *.diff,*.rej,*.patch      setf diff
557 " Dircolors
558 au BufNewFile,BufRead .dir_colors,/etc/DIR_COLORS       setf dircolors
560 " Diva (with Skill) or InstallShield
561 au BufNewFile,BufRead *.rul
562         \ if getline(1).getline(2).getline(3).getline(4).getline(5).getline(6) =~? 'InstallShield' |
563         \   setf ishd |
564         \ else |
565         \   setf diva |
566         \ endif
568 " DCL (Digital Command Language - vms) or DNS zone file
569 au BufNewFile,BufRead *.com                     call s:BindzoneCheck('dcl')
571 " DOT
572 au BufNewFile,BufRead *.dot                     setf dot
574 " Dylan - lid files
575 au BufNewFile,BufRead *.lid                     setf dylanlid
577 " Dylan - intr files (melange)
578 au BufNewFile,BufRead *.intr                    setf dylanintr
580 " Dylan
581 au BufNewFile,BufRead *.dylan                   setf dylan
583 " Microsoft Module Definition
584 au BufNewFile,BufRead *.def                     setf def
586 " Dracula
587 au BufNewFile,BufRead *.drac,*.drc,*lvs,*lpe    setf dracula
589 " dsl
590 au BufNewFile,BufRead *.dsl                     setf dsl
592 " DTD (Document Type Definition for XML)
593 au BufNewFile,BufRead *.dtd                     setf dtd
595 " EDIF (*.edf,*.edif,*.edn,*.edo)
596 au BufNewFile,BufRead *.ed\(f\|if\|n\|o\)       setf edif
598 " Embedix Component Description
599 au BufNewFile,BufRead *.ecd                     setf ecd
601 " Eiffel or Specman
602 au BufNewFile,BufRead *.e,*.E                   call s:FTe()
604 " Elinks configuration
605 au BufNewFile,BufRead */etc/elinks.conf,*/.elinks/elinks.conf   setf elinks
607 func! s:FTe()
608   let n = 1
609   while n < 100 && n < line("$")
610     if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$"
611       setf specman
612       return
613     endif
614     let n = n + 1
615   endwhile
616   setf eiffel
617 endfunc
619 " ERicsson LANGuage; Yaws is erlang too
620 au BufNewFile,BufRead *.erl,*.yaws              setf erlang
622 " Elm Filter Rules file
623 au BufNewFile,BufRead filter-rules              setf elmfilt
625 " ESMTP rc file
626 au BufNewFile,BufRead *esmtprc                  setf esmtprc
628 " ESQL-C
629 au BufNewFile,BufRead *.ec,*.EC                 setf esqlc
631 " Esterel
632 au BufNewFile,BufRead *.strl                    setf esterel
634 " Essbase script
635 au BufNewFile,BufRead *.csc                     setf csc
637 " Exim
638 au BufNewFile,BufRead exim.conf                 setf exim
640 " Expect
641 au BufNewFile,BufRead *.exp                     setf expect
643 " Exports
644 au BufNewFile,BufRead exports                   setf exports
646 " Factor
647 au BufNewFile,BufRead *.factor                  setf factor
649 " Fetchmail RC file
650 au BufNewFile,BufRead .fetchmailrc              setf fetchmail
652 " FlexWiki
653 au BufNewFile,BufRead *.wiki                    setf flexwiki
655 " Focus Executable
656 au BufNewFile,BufRead *.fex,*.focexec           setf focexec
658 " Focus Master file (but not for auto.master)
659 au BufNewFile,BufRead auto.master               setf conf
660 au BufNewFile,BufRead *.mas,*.master            setf master
662 " Forth
663 au BufNewFile,BufRead *.fs,*.ft                 setf forth
665 " Reva Forth
666 au BufNewFile,BufRead *.frt                     setf reva
668 " Fortran
669 if has("fname_case")
670   au BufNewFile,BufRead *.F,*.FOR,*.FPP,*.FTN,*.F77,*.F90,*.F95  setf fortran
671 endif
672 au BufNewFile,BufRead   *.f,*.for,*.fortran,*.fpp,*.ftn,*.f77,*.f90,*.f95  setf fortran
674 " FStab
675 au BufNewFile,BufRead fstab,mtab                setf fstab
677 " GDB command files
678 au BufNewFile,BufRead .gdbinit                  setf gdb
680 " GDMO
681 au BufNewFile,BufRead *.mo,*.gdmo               setf gdmo
683 " Gedcom
684 au BufNewFile,BufRead *.ged                     setf gedcom
686 " GIT
687 autocmd BufNewFile,BufRead *.git/COMMIT_EDITMSG    setf gitcommit
688 autocmd BufNewFile,BufRead *.git/config,.gitconfig setf gitconfig
689 autocmd BufNewFile,BufRead .msg.[0-9]*
690       \ if getline(1) =~ '^From.*# This line is ignored.$' |
691       \   setf gitsendemail |
692       \ endif
694 " Gkrellmrc
695 au BufNewFile,BufRead gkrellmrc,gkrellmrc_?     setf gkrellmrc
697 " GP scripts (2.0 and onward)
698 au BufNewFile,BufRead *.gp,.gprc                setf gp
700 " GPG
701 au BufNewFile,BufRead */.gnupg/options          setf gpg
702 au BufNewFile,BufRead */.gnupg/gpg.conf         setf gpg
703 au BufNewFile,BufRead /usr/**/gnupg/options.skel setf gpg
705 " Gnuplot scripts
706 au BufNewFile,BufRead *.gpi                     setf gnuplot
708 " GrADS scripts
709 au BufNewFile,BufRead *.gs                      setf grads
711 " Gretl
712 au BufNewFile,BufRead *.gretl                   setf gretl
714 " Groovy
715 au BufNewFile,BufRead *.groovy                  setf groovy
717 " GNU Server Pages
718 au BufNewFile,BufRead *.gsp                     setf gsp
720 " Group file
721 au BufNewFile,BufRead /etc/group                setf group
723 " GTK RC
724 au BufNewFile,BufRead .gtkrc,gtkrc              setf gtkrc
726 " Hamster Classic | Playground files
727 au BufNewFile,BufRead *.hsc,*.hsm               setf hamster
729 " Haskell
730 au BufNewFile,BufRead *.hs                      setf haskell
731 au BufNewFile,BufRead *.lhs                     setf lhaskell
732 au BufNewFile,BufRead *.chs                     setf chaskell
734 " Hercules
735 au BufNewFile,BufRead *.vc,*.ev,*.rs,*.sum,*.errsum     setf hercules
737 " HEX (Intel)
738 au BufNewFile,BufRead *.hex,*.h32               setf hex
740 " Tilde (must be before HTML)
741 au BufNewFile,BufRead *.t.html                  setf tilde
743 " HTML (.shtml and .stm for server side)
744 au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm  call s:FThtml()
746 " Distinguish between HTML, XHTML and Django
747 func! s:FThtml()
748   let n = 1
749   while n < 10 && n < line("$")
750     if getline(n) =~ '\<DTD\s\+XHTML\s'
751       setf xhtml
752       return
753     endif
754     if getline(n) =~ '{%\s*\(extends\|block\)\>'
755       setf htmldjango
756       return
757     endif
758     let n = n + 1
759   endwhile
760   setf html
761 endfunc
763 " HTML with Ruby - eRuby
764 au BufNewFile,BufRead *.erb,*.rhtml             setf eruby
766 " HTML with M4
767 au BufNewFile,BufRead *.html.m4                 setf htmlm4
769 " HTML Cheetah template
770 au BufNewFile,BufRead *.tmpl                    setf htmlcheetah
772 " Host config
773 au BufNewFile,BufRead /etc/host.conf            setf hostconf
775 " Hyper Builder
776 au BufNewFile,BufRead *.hb                      setf hb
778 " Icon
779 au BufNewFile,BufRead *.icn                     setf icon
781 " IDL (Interface Description Language)
782 au BufNewFile,BufRead *.idl                     call s:FTidl()
784 " Distinguish between standard IDL and MS-IDL
785 func! s:FTidl()
786   let n = 1
787   while n < 50 && n < line("$")
788     if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"'
789       setf msidl
790       return
791     endif
792     let n = n + 1
793   endwhile
794   setf idl
795 endfunc
797 " Microsoft IDL (Interface Description Language)  Also *.idl
798 " MOF = WMI (Windows Management Instrumentation) Managed Object Format
799 au BufNewFile,BufRead *.odl,*.mof               setf msidl
801 " Icewm menu
802 au BufNewFile,BufRead */.icewm/menu             setf icemenu
804 " Indent profile (must come before IDL *.pro!)
805 au BufNewFile,BufRead .indent.pro               setf indent
806 au BufNewFile,BufRead indent.pro                call s:ProtoCheck('indent')
808 " IDL (Interactive Data Language)
809 au BufNewFile,BufRead *.pro                     call s:ProtoCheck('idlang')
811 " Distinguish between "default" and Cproto prototype file. */
812 func! s:ProtoCheck(default)
813   " Cproto files have a comment in the first line and a function prototype in
814   " the second line, it always ends in ";".  Indent files may also have
815   " comments, thus we can't match comments to see the difference.
816   if getline(2) =~ ';$'
817     setf cpp
818   else
819     exe 'setf ' . a:default
820   endif
821 endfunc
824 " Indent RC
825 au BufNewFile,BufRead indentrc                  setf indentrc
827 " Inform
828 au BufNewFile,BufRead *.inf,*.INF               setf inform
830 " Initng
831 au BufNewFile,BufRead /etc/initng/**/*.i,*.ii   setf initng
833 " Ipfilter
834 au BufNewFile,BufRead ipf.conf,ipf6.conf,ipf.rules      setf ipfilter
836 " Informix 4GL (source - canonical, include file, I4GL+M4 preproc.)
837 au BufNewFile,BufRead *.4gl,*.4gh,*.m4gl        setf fgl
839 " .INI file for MSDOS
840 au BufNewFile,BufRead *.ini                     setf dosini
842 " SysV Inittab
843 au BufNewFile,BufRead inittab                   setf inittab
845 " Inno Setup
846 au BufNewFile,BufRead *.iss                     setf iss
848 " JAL
849 au BufNewFile,BufRead *.jal,*.JAL               setf jal
851 " Jam
852 au BufNewFile,BufRead *.jpl,*.jpr               setf jam
854 " Java
855 au BufNewFile,BufRead *.java,*.jav              setf java
857 " JavaCC
858 au BufNewFile,BufRead *.jj,*.jjt                setf javacc
860 " JavaScript, ECMAScript
861 au BufNewFile,BufRead *.js,*.javascript,*.es    setf javascript
863 " Java Server Pages
864 au BufNewFile,BufRead *.jsp                     setf jsp
866 " Java Properties resource file (note: doesn't catch font.properties.pl)
867 au BufNewFile,BufRead *.properties,*.properties_??,*.properties_??_??   setf jproperties
868 au BufNewFile,BufRead *.properties_??_??_*      call s:StarSetf('jproperties')
870 " Jess
871 au BufNewFile,BufRead *.clp                     setf jess
873 " Jgraph
874 au BufNewFile,BufRead *.jgr                     setf jgraph
876 " Kixtart
877 au BufNewFile,BufRead *.kix                     setf kix
879 " Kimwitu[++]
880 au BufNewFile,BufRead *.k                       setf kwt
882 " KDE script
883 au BufNewFile,BufRead *.ks                      setf kscript
885 " Kconfig
886 au BufNewFile,BufRead Kconfig,Kconfig.debug     setf kconfig
888 " Lace (ISE)
889 au BufNewFile,BufRead *.ace,*.ACE               setf lace
891 " Latte
892 au BufNewFile,BufRead *.latte,*.lte             setf latte
894 " Limits
895 au BufNewFile,BufRead /etc/limits               setf limits
897 " LambdaProlog (*.mod too, see Modsim)
898 au BufNewFile,BufRead *.sig                     setf lprolog
900 " LDAP LDIF
901 au BufNewFile,BufRead *.ldif                    setf ldif
903 " Ld loader
904 au BufNewFile,BufRead *.ld                      setf ld
906 " Lex
907 au BufNewFile,BufRead *.lex,*.l                 setf lex
909 " Libao
910 au BufNewFile,BufRead /etc/libao.conf,*/.libao  setf libao
912 " Libsensors
913 au BufNewFile,BufRead /etc/sensors.conf         setf sensors
915 " LFTP
916 au BufNewFile,BufRead lftp.conf,.lftprc,*lftp/rc        setf lftp
918 " Lifelines (or Lex for C++!)
919 au BufNewFile,BufRead *.ll                      setf lifelines
921 " Lilo: Linux loader
922 au BufNewFile,BufRead lilo.conf*                call s:StarSetf('lilo')
924 " Lisp (*.el = ELisp, *.cl = Common Lisp, *.jl = librep Lisp)
925 if has("fname_case")
926   au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,*.L,.emacs,.sawfishrc setf lisp
927 else
928   au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,.emacs,.sawfishrc setf lisp
929 endif
931 " SBCL implementation of Common Lisp
932 au BufNewFile,BufRead sbclrc,.sbclrc            setf lisp
934 " Lite
935 au BufNewFile,BufRead *.lite,*.lt               setf lite
937 " LiteStep RC files
938 au BufNewFile,BufRead */LiteStep/*/*.rc         setf litestep
940 " Login access
941 au BufNewFile,BufRead /etc/login.access         setf loginaccess
943 " Login defs
944 au BufNewFile,BufRead /etc/login.defs           setf logindefs
946 " Logtalk
947 au BufNewFile,BufRead *.lgt                     setf logtalk
949 " LOTOS
950 au BufNewFile,BufRead *.lot,*.lotos             setf lotos
952 " Lout (also: *.lt)
953 au BufNewFile,BufRead *.lou,*.lout              setf lout
955 " Lua
956 au BufNewFile,BufRead *.lua                     setf lua
958 " Lynx style file (or LotusScript!)
959 au BufNewFile,BufRead *.lss                     setf lss
961 " M4
962 au BufNewFile,BufRead *.m4
963         \ if expand("<afile>") !~? 'html.m4$\|fvwm2rc' | setf m4 | endif
965 " MaGic Point
966 au BufNewFile,BufRead *.mgp                     setf mgp
968 " Mail (for Elm, trn, mutt, muttng, rn, slrn)
969 au 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
971 " Mail aliases
972 au BufNewFile,BufRead /etc/mail/aliases,/etc/aliases    setf mailaliases
974 " Mailcap configuration file
975 au BufNewFile,BufRead .mailcap,mailcap          setf mailcap
977 " Makefile
978 au BufNewFile,BufRead *[mM]akefile,*.mk,*.mak,*.dsp setf make
980 " MakeIndex
981 au BufNewFile,BufRead *.ist,*.mst               setf ist
983 " Manpage
984 au BufNewFile,BufRead *.man                     setf man
986 " Man config
987 au BufNewFile,BufRead /etc/man.conf,man.config  setf manconf
989 " Maple V
990 au BufNewFile,BufRead *.mv,*.mpl,*.mws          setf maple
992 " Mason
993 au BufNewFile,BufRead *.mason,*.mhtml           setf mason
995 " Matlab or Objective C
996 au BufNewFile,BufRead *.m                       call s:FTm()
998 func! s:FTm()
999   let n = 1
1000   while n < 10
1001     let line = getline(n)
1002     if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)'
1003       setf objc
1004       return
1005     endif
1006     if line =~ '^\s*%'
1007       setf matlab
1008       return
1009     endif
1010     if line =~ '^\s*(\*'
1011       setf mma
1012       return
1013     endif
1014     let n = n + 1
1015   endwhile
1016   if exists("g:filetype_m")
1017     exe "setf " . g:filetype_m
1018   else
1019     setf matlab
1020   endif
1021 endfunc
1023 " Mathematica notebook
1024 au BufNewFile,BufRead *.nb                      setf mma
1026 " Maya Extension Language
1027 au BufNewFile,BufRead *.mel                     setf mel
1029 " Messages
1030 au BufNewFile,BufRead /var/log/messages,/var/log/messages.*[0-9]  setf messages
1032 " Metafont
1033 au BufNewFile,BufRead *.mf                      setf mf
1035 " MetaPost
1036 au BufNewFile,BufRead *.mp                      setf mp
1038 " MGL
1039 au BufNewFile,BufRead *.mgl                     setf mgl
1041 " MMIX or VMS makefile
1042 au BufNewFile,BufRead *.mms                     call s:FTmms()
1044 " Symbian meta-makefile definition (MMP)
1045 au BufNewFile,BufRead *.mmp                     setf mmp
1047 func! s:FTmms()
1048   let n = 1
1049   while n < 10
1050     let line = getline(n)
1051     if line =~ '^\s*\(%\|//\)' || line =~ '^\*'
1052       setf mmix
1053       return
1054     endif
1055     if line =~ '^\s*#'
1056       setf make
1057       return
1058     endif
1059     let n = n + 1
1060   endwhile
1061   setf mmix
1062 endfunc
1065 " Modsim III (or LambdaProlog)
1066 au BufNewFile,BufRead *.mod
1067         \ if getline(1) =~ '\<module\>' |
1068         \   setf lprolog |
1069         \ else |
1070         \   setf modsim3 |
1071         \ endif
1073 " Modula 2
1074 au BufNewFile,BufRead *.m2,*.DEF,*.MOD,*.md,*.mi setf modula2
1076 " Modula 3 (.m3, .i3, .mg, .ig)
1077 au BufNewFile,BufRead *.[mi][3g]                setf modula3
1079 " Monk
1080 au BufNewFile,BufRead *.isc,*.monk,*.ssc,*.tsc  setf monk
1082 " MOO
1083 au BufNewFile,BufRead *.moo                     setf moo
1085 " Modconf
1086 au BufNewFile,BufRead /etc/modules.conf,/etc/conf.modules       setf modconf
1087 au BufNewFile,BufRead /etc/modutils/*
1088         \ if executable(expand("<afile>")) != 1
1089         \|  call s:StarSetf('modconf')
1090         \|endif
1092 " Mplayer config
1093 au BufNewFile,BufRead mplayer.conf,*/.mplayer/config    setf mplayerconf
1095 " Moterola S record
1096 au BufNewFile,BufRead *.s19,*.s28,*.s37         setf srec
1098 " Mrxvtrc
1099 au BufNewFile,BufRead mrxvtrc,.mrxvtrc          setf mrxvtrc
1101 " Msql
1102 au BufNewFile,BufRead *.msql                    setf msql
1104 " Mysql
1105 au BufNewFile,BufRead *.mysql                   setf mysql
1107 " M$ Resource files
1108 au BufNewFile,BufRead *.rc                      setf rc
1110 " MuPAD source
1111 au BufRead,BufNewFile *.mu                      setf mupad
1113 " Mush
1114 au BufNewFile,BufRead *.mush                    setf mush
1116 " Mutt setup file (also for Muttng)
1117 au BufNewFile,BufRead Mutt{ng,}rc               setf muttrc
1119 " Nano
1120 au BufNewFile,BufRead /etc/nanorc,.nanorc       setf nanorc
1122 " Nastran input/DMAP
1123 "au BufNewFile,BufRead *.dat                    setf nastran
1125 " Natural
1126 au BufNewFile,BufRead *.NS[ACGLMNPS]            setf natural
1128 " Netrc
1129 au BufNewFile,BufRead .netrc                    setf netrc
1131 " Novell netware batch files
1132 au BufNewFile,BufRead *.ncf                     setf ncf
1134 " Nroff/Troff (*.ms and *.t are checked below)
1135 au BufNewFile,BufRead *.me
1136         \ if expand("<afile>") != "read.me" && expand("<afile>") != "click.me" |
1137         \   setf nroff |
1138         \ endif
1139 au BufNewFile,BufRead *.tr,*.nr,*.roff,*.tmac,*.mom     setf nroff
1140 au BufNewFile,BufRead *.[1-9]                   call s:FTnroff()
1142 " This function checks if one of the first five lines start with a dot.  In
1143 " that case it is probably an nroff file: 'filetype' is set and 1 is returned.
1144 func! s:FTnroff()
1145   if getline(1)[0] . getline(2)[0] . getline(3)[0] . getline(4)[0] . getline(5)[0] =~ '\.'
1146     setf nroff
1147     return 1
1148   endif
1149   return 0
1150 endfunc
1152 " Nroff or Objective C++
1153 au BufNewFile,BufRead *.mm                      call s:FTmm()
1155 func! s:FTmm()
1156   let n = 1
1157   while n < 10
1158     let line = getline(n)
1159     if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)'
1160       setf objcpp
1161       return
1162     endif
1163     let n = n + 1
1164   endwhile
1165   setf nroff
1166 endfunc
1168 " Not Quite C
1169 au BufNewFile,BufRead *.nqc                     setf nqc
1171 " NSIS
1172 au BufNewFile,BufRead *.nsi                     setf nsis
1174 " OCAML
1175 au BufNewFile,BufRead *.ml,*.mli,*.mll,*.mly    setf ocaml
1177 " Occam
1178 au BufNewFile,BufRead *.occ                     setf occam
1180 " Omnimark
1181 au BufNewFile,BufRead *.xom,*.xin               setf omnimark
1183 " OpenROAD
1184 au BufNewFile,BufRead *.or                      setf openroad
1186 " OPL
1187 au BufNewFile,BufRead *.[Oo][Pp][Ll]            setf opl
1189 " Oracle config file
1190 au BufNewFile,BufRead *.ora                     setf ora
1192 " Packet filter conf
1193 au BufNewFile,BufRead pf.conf                   setf pf
1195 " Pam conf
1196 au BufNewFile,BufRead /etc/pam.conf             setf pamconf
1198 " PApp
1199 au BufNewFile,BufRead *.papp,*.pxml,*.pxsl      setf papp
1201 " Password file
1202 au BufNewFile,BufRead /etc/passwd,/etc/shadow,/etc/shadow- setf passwd
1204 " Pascal (also *.p)
1205 au BufNewFile,BufRead *.pas                     setf pascal
1207 " Delphi project file
1208 au BufNewFile,BufRead *.dpr                     setf pascal
1210 " PDF
1211 au BufNewFile,BufRead *.pdf                     setf pdf
1213 " Perl
1214 if has("fname_case")
1215   au BufNewFile,BufRead *.pl,*.PL               call s:FTpl()
1216 else
1217   au BufNewFile,BufRead *.pl                    call s:FTpl()
1218 endif
1219 au BufNewFile,BufRead *.plx                     setf perl
1221 func! s:FTpl()
1222   if exists("g:filetype_pl")
1223     exe "setf " . g:filetype_pl
1224   else
1225     " recognize Prolog by specific text in the first non-empty line
1226     " require a blank after the '%' because Perl uses "%list" and "%translate"
1227     let l = getline(nextnonblank(1))
1228     if l =~ '\<prolog\>' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-'
1229       setf prolog
1230     else
1231       setf perl
1232     endif
1233   endif
1234 endfunc
1236 " Perl, XPM or XPM2
1237 au BufNewFile,BufRead *.pm
1238         \ if getline(1) =~ "XPM2" |
1239         \   setf xpm2 |
1240         \ elseif getline(1) =~ "XPM" |
1241         \   setf xpm |
1242         \ else |
1243         \   setf perl |
1244         \ endif
1246 " Perl POD
1247 au BufNewFile,BufRead *.pod                     setf pod
1249 " Php, php3, php4, etc.
1250 " Also Phtml (was used for PHP 2 in the past)
1251 " Also .ctp for Cake template file
1252 au BufNewFile,BufRead *.php,*.php\d,*.phtml,*.ctp       setf php
1254 " Pike
1255 au BufNewFile,BufRead *.pike,*.lpc,*.ulpc,*.pmod setf pike
1257 " Pinfo config
1258 au BufNewFile,BufRead */etc/pinforc,*/.pinforc  setf pinfo
1260 " Palm Resource compiler
1261 au BufNewFile,BufRead *.rcp                     setf pilrc
1263 " Pine config
1264 au BufNewFile,BufRead .pinerc,pinerc,.pinercex,pinercex         setf pine
1266 " PL/M (also: *.inp)
1267 au BufNewFile,BufRead *.plm,*.p36,*.pac         setf plm
1269 " PL/SQL
1270 au BufNewFile,BufRead *.pls,*.plsql             setf plsql
1272 " PLP
1273 au BufNewFile,BufRead *.plp                     setf plp
1275 " PO and PO template (GNU gettext)
1276 au BufNewFile,BufRead *.po,*.pot                setf po
1278 " Postfix main config
1279 au BufNewFile,BufRead main.cf                   setf pfmain
1281 " PostScript (+ font files, encapsulated PostScript, Adobe Illustrator)
1282 au BufNewFile,BufRead *.ps,*.pfa,*.afm,*.eps,*.epsf,*.epsi,*.ai   setf postscr
1284 " PostScript Printer Description
1285 au BufNewFile,BufRead *.ppd                     setf ppd
1287 " Povray
1288 au BufNewFile,BufRead *.pov                     setf pov
1290 " Povray configuration
1291 au BufNewFile,BufRead .povrayrc                 setf povini
1293 " Povray, PHP or assembly
1294 au BufNewFile,BufRead *.inc                     call s:FTinc()
1296 func! s:FTinc()
1297   if exists("g:filetype_inc")
1298     exe "setf " . g:filetype_inc
1299   else
1300     let lines = getline(1).getline(2).getline(3)
1301     if lines =~? "perlscript"
1302       setf aspperl
1303     elseif lines =~ "<%"
1304       setf aspvbs
1305     elseif lines =~ "<?"
1306       setf php
1307     else
1308       call s:FTasmsyntax()
1309       if exists("b:asmsyntax")
1310         exe "setf " . b:asmsyntax
1311       else
1312         setf pov
1313       endif
1314     endif
1315   endif
1316 endfunc
1318 " Printcap and Termcap
1319 au BufNewFile,BufRead *printcap
1320         \ let b:ptcap_type = "print" | setf ptcap
1321 au BufNewFile,BufRead *termcap
1322         \ let b:ptcap_type = "term" | setf ptcap
1324 " PCCTS / ANTRL
1325 "au BufNewFile,BufRead *.g                      setf antrl
1326 au BufNewFile,BufRead *.g                       setf pccts
1328 " PPWizard
1329 au BufNewFile,BufRead *.it,*.ih                 setf ppwiz
1331 " Oracle Pro*C/C++
1332 au BufNewFile,BufRead *.pc                      setf proc
1334 " Privoxy actions file
1335 au BufNewFile,BufRead *.action                  setf privoxy
1337 " Procmail
1338 au BufNewFile,BufRead .procmail,.procmailrc     setf procmail
1340 " Progress or CWEB
1341 au BufNewFile,BufRead *.w                       call s:FTprogress_cweb()
1343 func! s:FTprogress_cweb()
1344   if exists("g:filetype_w")
1345     exe "setf " . g:filetype_w
1346     return
1347   endif
1348   if getline(1) =~ '&ANALYZE' || getline(3) =~ '&GLOBAL-DEFINE'
1349     setf progress
1350   else
1351     setf cweb
1352   endif
1353 endfunc
1355 " Progress or assembly
1356 au BufNewFile,BufRead *.i                       call s:FTprogress_asm()
1358 func! s:FTprogress_asm()
1359   if exists("g:filetype_i")
1360     exe "setf " . g:filetype_i
1361     return
1362   endif
1363   " This function checks for an assembly comment the first ten lines.
1364   " If not found, assume Progress.
1365   let lnum = 1
1366   while lnum <= 10 && lnum < line('$')
1367     let line = getline(lnum)
1368     if line =~ '^\s*;' || line =~ '^\*'
1369       call s:FTasm()
1370       return
1371     elseif line !~ '^\s*$' || line =~ '^/\*'
1372       " Not an empty line: Doesn't look like valid assembly code.
1373       " Or it looks like a Progress /* comment
1374       break
1375     endif
1376     let lnum = lnum + 1
1377   endw
1378   setf progress
1379 endfunc
1381 " Progress or Pascal
1382 au BufNewFile,BufRead *.p                       call s:FTprogress_pascal()
1384 func! s:FTprogress_pascal()
1385   if exists("g:filetype_p")
1386     exe "setf " . g:filetype_p
1387     return
1388   endif
1389   " This function checks for valid Pascal syntax in the first ten lines.
1390   " Look for either an opening comment or a program start.
1391   " If not found, assume Progress.
1392   let lnum = 1
1393   while lnum <= 10 && lnum < line('$')
1394     let line = getline(lnum)
1395     if line =~ '^\s*\(program\|unit\|procedure\|function\|const\|type\|var\)\>'
1396         \ || line =~ '^\s*{' || line =~ '^\s*(\*'
1397       setf pascal
1398       return
1399     elseif line !~ '^\s*$' || line =~ '^/\*'
1400       " Not an empty line: Doesn't look like valid Pascal code.
1401       " Or it looks like a Progress /* comment
1402       break
1403     endif
1404     let lnum = lnum + 1
1405   endw
1406   setf progress
1407 endfunc
1410 " Software Distributor Product Specification File (POSIX 1387.2-1995)
1411 au BufNewFile,BufRead *.psf                     setf psf
1412 au BufNewFile,BufRead INDEX,INFO
1413         \ if getline(1) =~ '^\s*\(distribution\|installed_software\|root\|bundle\|product\)\s*$' |
1414         \   setf psf |
1415         \ endif
1417 " Prolog
1418 au BufNewFile,BufRead *.pdb                     setf prolog
1420 " Promela
1421 au BufNewFile,BufRead *.pml                     setf promela
1423 " Protocols
1424 au BufNewFile,BufRead /etc/protocols            setf protocols
1426 " Pyrex
1427 au BufNewFile,BufRead *.pyx,*.pxd               setf pyrex
1429 " Python
1430 au BufNewFile,BufRead *.py,*.pyw                setf python
1432 " Radiance
1433 au BufNewFile,BufRead *.rad,*.mat               setf radiance
1435 " Ratpoison config/command files
1436 au BufNewFile,BufRead .ratpoisonrc,ratpoisonrc  setf ratpoison
1438 " RCS file
1439 au BufNewFile,BufRead *\,v                      setf rcs
1441 " Readline
1442 au BufNewFile,BufRead .inputrc,inputrc          setf readline
1444 " Registry for MS-Windows
1445 au BufNewFile,BufRead *.reg
1446         \ if getline(1) =~? '^REGEDIT[0-9]*\s*$\|^Windows Registry Editor Version \d*\.\d*\s*$' | setf registry | endif
1448 " Renderman Interface Bytestream
1449 au BufNewFile,BufRead *.rib                     setf rib
1451 " Rexx
1452 au BufNewFile,BufRead *.rexx,*.rex,*.jrexx,*.rxj,*.orx  setf rexx
1454 " R (Splus)
1455 if has("fname_case")
1456   au BufNewFile,BufRead *.s,*.S                 setf r
1457 else
1458   au BufNewFile,BufRead *.s                     setf r
1459 endif
1461 " R Help file
1462 if has("fname_case")
1463   au BufNewFile,BufRead *.rd,*.Rd               setf rhelp
1464 else
1465   au BufNewFile,BufRead *.rd                    setf rhelp
1466 endif
1468 " R noweb file
1469 if has("fname_case")
1470   au BufNewFile,BufRead *.Rnw,*.rnw,*.Snw,*.snw         setf rnoweb
1471 else
1472   au BufNewFile,BufRead *.rnw,*.snw                     setf rnoweb
1473 endif
1475 " Rexx, Rebol or R
1476 au BufNewFile,BufRead *.r,*.R                   call s:FTr()
1478 func! s:FTr()
1479   let max = line("$") > 50 ? 50 : line("$")
1481   for n in range(1, max)
1482     " Rebol is easy to recognize, check for that first
1483     if getline(n) =~? '\<REBOL\>'
1484       setf rebol
1485       return
1486     endif
1487   endfor
1489   for n in range(1, max)
1490     " R has # comments
1491     if getline(n) =~ '^\s*#'
1492       setf r
1493       return
1494     endif
1495     " Rexx has /* comments */
1496     if getline(n) =~ '^\s*/\*'
1497       setf rexx
1498       return
1499     endif
1500   endfor
1502   " Nothing recognized, assume Rexx
1503   setf rexx
1504 endfunc
1506 " Remind
1507 au BufNewFile,BufRead .reminders*               call s:StarSetf('remind')
1509 " Resolv.conf
1510 au BufNewFile,BufRead resolv.conf               setf resolv
1512 " Relax NG Compact
1513 au BufNewFile,BufRead *.rnc                     setf rnc
1515 " RPL/2
1516 au BufNewFile,BufRead *.rpl                     setf rpl
1518 " Robots.txt
1519 au BufNewFile,BufRead robots.txt                setf robots
1521 " Rpcgen
1522 au BufNewFile,BufRead *.x                       setf rpcgen
1524 " reStructuredText Documentation Format
1525 au BufNewFile,BufRead *.rst                     setf rst
1527 " RTF
1528 au BufNewFile,BufRead *.rtf                     setf rtf
1530 " Ruby
1531 au BufNewFile,BufRead *.rb,*.rbw,*.gem,*.gemspec        setf ruby
1533 " Ruby on Rails
1534 au BufNewFile,BufRead *.builder,*.rxml,*.rjs    setf ruby
1536 " Rantfile and Rakefile is like Ruby
1537 au BufNewFile,BufRead [rR]antfile,*.rant,[rR]akefile,*.rake     setf ruby
1539 " S-lang (or shader language!)
1540 au BufNewFile,BufRead *.sl                      setf slang
1542 " Samba config
1543 au BufNewFile,BufRead smb.conf                  setf samba
1545 " SAS script
1546 au BufNewFile,BufRead *.sas                     setf sas
1548 " Sather
1549 au BufNewFile,BufRead *.sa                      setf sather
1551 " Scilab
1552 au BufNewFile,BufRead *.sci,*.sce               setf scilab
1554 " SD: Streaming Descriptors
1555 au BufNewFile,BufRead *.sd                      setf sd
1557 " SDL
1558 au BufNewFile,BufRead *.sdl,*.pr                setf sdl
1560 " sed
1561 au BufNewFile,BufRead *.sed                     setf sed
1563 " Sieve (RFC 3028)
1564 au BufNewFile,BufRead *.siv                     setf sieve
1566 " Sendmail
1567 au BufNewFile,BufRead sendmail.cf               setf sm
1569 " Sendmail .mc files are actually m4
1570 au BufNewFile,BufRead *.mc                      setf m4
1572 " Services
1573 au BufNewFile,BufRead /etc/services             setf services
1575 " Service Location config
1576 au BufNewFile,BufRead /etc/slp.conf             setf slpconf
1578 " Service Location registration
1579 au BufNewFile,BufRead /etc/slp.reg              setf slpreg
1581 " Service Location SPI
1582 au BufNewFile,BufRead /etc/slp.spi              setf slpspi
1584 " Setserial config
1585 au BufNewFile,BufRead /etc/serial.conf          setf setserial
1587 " SGML
1588 au BufNewFile,BufRead *.sgm,*.sgml
1589         \ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'linuxdoc' |
1590         \   setf sgmllnx |
1591         \ elseif getline(1) =~ '<!DOCTYPE.*DocBook' || getline(2) =~ '<!DOCTYPE.*DocBook' |
1592         \   let b:docbk_type="sgml" |
1593         \   setf docbk |
1594         \ else |
1595         \   setf sgml |
1596         \ endif
1598 " SGMLDECL
1599 au BufNewFile,BufRead *.decl,*.dcl,*.dec
1600         \ if getline(1).getline(2).getline(3) =~? '^<!SGML' |
1601         \    setf sgmldecl |
1602         \ endif
1604 " SGML catalog file
1605 au BufNewFile,BufRead catalog                   setf catalog
1606 au BufNewFile,BufRead sgml.catalog*             call s:StarSetf('catalog')
1608 " Shell scripts (sh, ksh, bash, bash2, csh); Allow .profile_foo etc.
1609 " Gentoo ebuilds are actually bash scripts
1610 au BufNewFile,BufRead .bashrc*,bashrc,bash.bashrc,.bash_profile*,.bash_logout*,*.bash,*.ebuild call SetFileTypeSH("bash")
1611 au BufNewFile,BufRead .kshrc*,*.ksh call SetFileTypeSH("ksh")
1612 au BufNewFile,BufRead /etc/profile,.profile*,*.sh,*.env call SetFileTypeSH(getline(1))
1614 " Also called from scripts.vim.
1615 func! SetFileTypeSH(name)
1616   if expand("<amatch>") =~ g:ft_ignore_pat
1617     return
1618   endif
1619   if a:name =~ '\<ksh\>'
1620     let b:is_kornshell = 1
1621     if exists("b:is_bash")
1622       unlet b:is_bash
1623     endif
1624     if exists("b:is_sh")
1625       unlet b:is_sh
1626     endif
1627   elseif exists("g:bash_is_sh") || a:name =~ '\<bash\>' || a:name =~ '\<bash2\>'
1628     let b:is_bash = 1
1629     if exists("b:is_kornshell")
1630       unlet b:is_kornshell
1631     endif
1632     if exists("b:is_sh")
1633       unlet b:is_sh
1634     endif
1635   elseif a:name =~ '\<sh\>'
1636     let b:is_sh = 1
1637     if exists("b:is_kornshell")
1638       unlet b:is_kornshell
1639     endif
1640     if exists("b:is_bash")
1641       unlet b:is_bash
1642     endif
1643   endif
1644   call SetFileTypeShell("sh")
1645 endfunc
1647 " For shell-like file types, check for an "exec" command hidden in a comment,
1648 " as used for Tcl.
1649 " Also called from scripts.vim, thus can't be local to this script.
1650 func! SetFileTypeShell(name)
1651   if expand("<amatch>") =~ g:ft_ignore_pat
1652     return
1653   endif
1654   let l = 2
1655   while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)'
1656     " Skip empty and comment lines.
1657     let l = l + 1
1658   endwhile
1659   if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$'
1660     " Found an "exec" line after a comment with continuation
1661     let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '')
1662     if n =~ '\<tclsh\|\<wish'
1663       setf tcl
1664       return
1665     endif
1666   endif
1667   exe "setf " . a:name
1668 endfunc
1670 " tcsh scripts
1671 au BufNewFile,BufRead .tcshrc*,*.tcsh,tcsh.tcshrc,tcsh.login    call SetFileTypeShell("tcsh")
1673 " csh scripts, but might also be tcsh scripts (on some systems csh is tcsh)
1674 au BufNewFile,BufRead .login*,.cshrc*,csh.cshrc,csh.login,csh.logout,*.csh,.alias  call s:CSH()
1676 func! s:CSH()
1677   if exists("g:filetype_csh")
1678     call SetFileTypeShell(g:filetype_csh)
1679   elseif &shell =~ "tcsh"
1680     call SetFileTypeShell("tcsh")
1681   else
1682     call SetFileTypeShell("csh")
1683   endif
1684 endfunc
1686 " Z-Shell script
1687 au BufNewFile,BufRead .zprofile,/etc/zprofile,.zfbfmarks  setf zsh
1688 au BufNewFile,BufRead .zsh*,.zlog*,.zcompdump*  call s:StarSetf('zsh')
1690 " Scheme
1691 au BufNewFile,BufRead *.scm,*.ss                setf scheme
1693 " Screen RC
1694 au BufNewFile,BufRead .screenrc,screenrc        setf screen
1696 " Simula
1697 au BufNewFile,BufRead *.sim                     setf simula
1699 " SINDA
1700 au BufNewFile,BufRead *.sin,*.s85               setf sinda
1702 " SiSU
1703 au BufNewFile,BufRead *.sst,*.ssm,*.ssi,*.-sst,*._sst setf sisu
1704 au BufNewFile,BufRead *.sst.meta,*.-sst.meta,*._sst.meta setf sisu
1706 " SKILL
1707 au BufNewFile,BufRead *.il,*.ils,*.cdf          setf skill
1709 " SLRN
1710 au BufNewFile,BufRead .slrnrc                   setf slrnrc
1711 au BufNewFile,BufRead *.score                   setf slrnsc
1713 " Smalltalk (and TeX)
1714 au BufNewFile,BufRead *.st                      setf st
1715 au BufNewFile,BufRead *.cls
1716         \ if getline(1) =~ '^%' |
1717         \  setf tex |
1718         \ else |
1719         \  setf st |
1720         \ endif
1722 " Smarty templates
1723 au BufNewFile,BufRead *.tpl                     setf smarty
1725 " SMIL or XML
1726 au BufNewFile,BufRead *.smil
1727         \ if getline(1) =~ '<?\s*xml.*?>' |
1728         \   setf xml |
1729         \ else |
1730         \   setf smil |
1731         \ endif
1733 " SMIL or SNMP MIB file
1734 au BufNewFile,BufRead *.smi
1735         \ if getline(1) =~ '\<smil\>' |
1736         \   setf smil |
1737         \ else |
1738         \   setf mib |
1739         \ endif
1741 " SMITH
1742 au BufNewFile,BufRead *.smt,*.smith             setf smith
1744 " Snobol4 and spitbol
1745 au BufNewFile,BufRead *.sno,*.spt               setf snobol4
1747 " SNMP MIB files
1748 au BufNewFile,BufRead *.mib,*.my                setf mib
1750 " Snort Configuration
1751 au BufNewFile,BufRead *.hog,snort.conf,vision.conf      setf hog
1752 au BufNewFile,BufRead *.rules                   call s:FTRules()
1754 let s:ft_rules_udev_rules_pattern = '^\s*\cudev_rules\s*=\s*"\([^"]\{-1,}\)/*".*'
1755 func! s:FTRules()
1756   try
1757     let config_lines = readfile('/etc/udev/udev.conf')
1758   catch /^Vim\%((\a\+)\)\=:E484/
1759     setf hog
1760     return
1761   endtry
1762   for line in config_lines
1763     if line =~ s:ft_rules_udev_rules_pattern
1764       let udev_rules = substitute(line, s:ft_rules_udev_rules_pattern, '\1', "")
1765       if expand('<amatch>:p:h') == udev_rules
1766         setf udevrules
1767       endif
1768       break
1769     endif
1770   endfor
1771   setf hog
1772 endfunc
1775 " Spec (Linux RPM)
1776 au BufNewFile,BufRead *.spec                    setf spec
1778 " Speedup (AspenTech plant simulator)
1779 au BufNewFile,BufRead *.speedup,*.spdata,*.spd  setf spup
1781 " Slice
1782 au BufNewFile,BufRead *.ice                     setf slice
1784 " Spice
1785 au BufNewFile,BufRead *.sp,*.spice              setf spice
1787 " Spyce
1788 au BufNewFile,BufRead *.spy,*.spi               setf spyce
1790 " Squid
1791 au BufNewFile,BufRead squid.conf                setf squid
1793 " SQL for Oracle Designer
1794 au BufNewFile,BufRead *.tyb,*.typ,*.tyc,*.pkb,*.pks     setf sql
1796 " SQL
1797 au BufNewFile,BufRead *.sql                     call s:SQL()
1799 func! s:SQL()
1800   if exists("g:filetype_sql")
1801     exe "setf " . g:filetype_sql
1802   else
1803     setf sql
1804   endif
1805 endfunc
1807 " SQLJ
1808 au BufNewFile,BufRead *.sqlj                    setf sqlj
1810 " SQR
1811 au BufNewFile,BufRead *.sqr,*.sqi               setf sqr
1813 " OpenSSH configuration
1814 au BufNewFile,BufRead ssh_config,*/.ssh/config  setf sshconfig
1816 " OpenSSH server configuration
1817 au BufNewFile,BufRead sshd_config               setf sshdconfig
1819 " Stata
1820 au BufNewFile,BufRead *.ado,*.class,*.do,*.imata,*.mata   setf stata
1822 " SMCL
1823 au BufNewFile,BufRead *.hlp,*.ihlp,*.smcl       setf smcl
1825 " Stored Procedures
1826 au BufNewFile,BufRead *.stp                     setf stp
1828 " Standard ML
1829 au BufNewFile,BufRead *.sml                     setf sml
1831 " Sratus VOS command macro
1832 au BufNewFile,BufRead *.cm                      setf voscm
1834 " Sysctl
1835 au BufNewFile,BufRead /etc/sysctl.conf          setf sysctl
1837 " Sudoers
1838 au BufNewFile,BufRead /etc/sudoers,sudoers.tmp  setf sudoers
1840 " If the file has an extension of 't' and is in a directory 't' then it is
1841 " almost certainly a Perl test file.
1842 " If the first line starts with '#' and contains 'perl' it's probably a Perl
1843 " file.
1844 " (Slow test) If a file contains a 'use' statement then it is almost certainly
1845 " a Perl file.
1846 func! s:FTperl()
1847   if expand("%:e") == 't' && expand("%:p:h:t") == 't'
1848     setf perl
1849     return 1
1850   endif
1851   if getline(1)[0] == '#' && getline(1) =~ 'perl'
1852     setf perl
1853     return 1
1854   endif
1855   if search('^use\s\s*\k', 'nc', 30)
1856     setf perl
1857     return 1
1858   endif
1859   return 0
1860 endfunc
1862 " Tads (or Nroff or Perl test file)
1863 au BufNewFile,BufRead *.t
1864         \ if !s:FTnroff() && !s:FTperl() | setf tads | endif
1866 " Tags
1867 au BufNewFile,BufRead tags                      setf tags
1869 " TAK
1870 au BufNewFile,BufRead *.tak                     setf tak
1872 " Tcl (JACL too)
1873 au BufNewFile,BufRead *.tcl,*.tk,*.itcl,*.itk,*.jacl    setf tcl
1875 " TealInfo
1876 au BufNewFile,BufRead *.tli                     setf tli
1878 " Telix Salt
1879 au BufNewFile,BufRead *.slt                     setf tsalt
1881 " Terminfo
1882 au BufNewFile,BufRead *.ti                      setf terminfo
1884 " TeX
1885 au BufNewFile,BufRead *.latex,*.sty,*.dtx,*.ltx,*.bbl   setf tex
1886 au BufNewFile,BufRead *.tex                     call s:FTtex()
1888 " Choose context, plaintex, or tex (LaTeX) based on these rules:
1889 " 1. Check the first line of the file for "%&<format>".
1890 " 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords.
1891 " 3. Default to "latex" or to g:tex_flavor, can be set in user's vimrc.
1892 func! s:FTtex()
1893   let firstline = getline(1)
1894   if firstline =~ '^%&\s*\a\+'
1895     let format = tolower(matchstr(firstline, '\a\+'))
1896     let format = substitute(format, 'pdf', '', '')
1897     if format == 'tex'
1898       let format = 'plain'
1899     endif
1900   else
1901     " Default value, may be changed later:
1902     let format = exists("g:tex_flavor") ? g:tex_flavor : 'plain'
1903     " Save position, go to the top of the file, find first non-comment line.
1904     let save_cursor = getpos('.')
1905     call cursor(1,1)
1906     let firstNC = search('^\s*[^[:space:]%]', 'c', 1000)
1907     if firstNC " Check the next thousand lines for a LaTeX or ConTeXt keyword.
1908       let lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>'
1909       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\>'
1910       let kwline = search('^\s*\\\%(' . lpat . '\)\|^\s*\\\(' . cpat . '\)',
1911                               \ 'cnp', firstNC + 1000)
1912       if kwline == 1    " lpat matched
1913         let format = 'latex'
1914       elseif kwline == 2        " cpat matched
1915         let format = 'context'
1916       endif             " If neither matched, keep default set above.
1917       " let lline = search('^\s*\\\%(' . lpat . '\)', 'cn', firstNC + 1000)
1918       " let cline = search('^\s*\\\%(' . cpat . '\)', 'cn', firstNC + 1000)
1919       " if cline > 0
1920       "   let format = 'context'
1921       " endif
1922       " if lline > 0 && (cline == 0 || cline > lline)
1923       "   let format = 'tex'
1924       " endif
1925     endif " firstNC
1926     call setpos('.', save_cursor)
1927   endif " firstline =~ '^%&\s*\a\+'
1929   " Translation from formats to file types.  TODO:  add AMSTeX, RevTex, others?
1930   if format == 'plain'
1931     setf plaintex
1932   elseif format == 'context'
1933     setf context
1934   else " probably LaTeX
1935     setf tex
1936   endif
1937   return
1938 endfunc
1940 " ConTeXt
1941 au BufNewFile,BufRead tex/context/*/*.tex,*.mkii,*.mkiv   setf context
1943 " Texinfo
1944 au BufNewFile,BufRead *.texinfo,*.texi,*.txi    setf texinfo
1946 " TeX configuration
1947 au BufNewFile,BufRead texmf.cnf                 setf texmf
1949 " Tidy config
1950 au BufNewFile,BufRead .tidyrc,tidyrc            setf tidy
1952 " TF mud client
1953 au BufNewFile,BufRead *.tf,.tfrc,tfrc           setf tf
1955 " TPP - Text Presentation Program
1956 au BufNewFile,BufReadPost *.tpp                 setf tpp
1958 " Trustees
1959 au BufNewFile,BufRead trustees.conf             setf trustees
1961 " TSS - Geometry
1962 au BufNewFile,BufReadPost *.tssgm               setf tssgm
1964 " TSS - Optics
1965 au BufNewFile,BufReadPost *.tssop               setf tssop
1967 " TSS - Command Line (temporary)
1968 au BufNewFile,BufReadPost *.tsscl               setf tsscl
1970 " Motif UIT/UIL files
1971 au BufNewFile,BufRead *.uit,*.uil               setf uil
1973 " Udev conf
1974 au BufNewFile,BufRead /etc/udev/udev.conf       setf udevconf
1976 " Udev rules
1977 au BufNewFile,BufRead /etc/udev/rules.d/*.rules setf udevrules
1979 " Udev permissions
1980 au BufNewFile,BufRead /etc/udev/permissions.d/*.permissions setf udevperm
1982 " Udev symlinks config
1983 au BufNewFile,BufRead /etc/udev/cdsymlinks.conf setf sh
1985 " UnrealScript
1986 au BufNewFile,BufRead *.uc                      setf uc
1988 " Updatedb
1989 au BufNewFile,BufRead /etc/updatedb.conf        setf updatedb
1991 " Vera
1992 au BufNewFile,BufRead *.vr,*.vri,*.vrh          setf vera
1994 " Verilog HDL
1995 au BufNewFile,BufRead *.v                       setf verilog
1997 " Verilog-AMS HDL
1998 au BufNewFile,BufRead *.va,*.vams               setf verilogams
2000 " VHDL
2001 au BufNewFile,BufRead *.hdl,*.vhd,*.vhdl,*.vbe,*.vst  setf vhdl
2002 au BufNewFile,BufRead *.vhdl_[0-9]*             call s:StarSetf('vhdl')
2004 " Vim script
2005 au BufNewFile,BufRead *.vim,*.vba,.exrc,_exrc   setf vim
2007 " Viminfo file
2008 au BufNewFile,BufRead .viminfo,_viminfo         setf viminfo
2010 " Virata Config Script File
2011 au BufRead,BufNewFile *.hw,*.module,*.pkg       setf virata
2013 " Visual Basic (also uses *.bas) or FORM
2014 au BufNewFile,BufRead *.frm                     call s:FTVB("form")
2016 " SaxBasic is close to Visual Basic
2017 au BufNewFile,BufRead *.sba                     setf vb
2019 " Vgrindefs file
2020 au BufNewFile,BufRead vgrindefs                 setf vgrindefs
2022 " VRML V1.0c
2023 au BufNewFile,BufRead *.wrl                     setf vrml
2025 " Webmacro
2026 au BufNewFile,BufRead *.wm                      setf webmacro
2028 " Wget config
2029 au BufNewFile,BufRead .wgetrc,wgetrc            setf wget
2031 " Website MetaLanguage
2032 au BufNewFile,BufRead *.wml                     setf wml
2034 " Winbatch
2035 au BufNewFile,BufRead *.wbt                     setf winbatch
2037 " WSML
2038 au BufNewFile,BufRead *.wsml                    setf wsml
2040 " WvDial
2041 au BufNewFile,BufRead wvdial.conf,.wvdialrc     setf wvdial
2043 " CVS RC file
2044 au BufNewFile,BufRead .cvsrc                    setf cvsrc
2046 " CVS commit file
2047 au BufNewFile,BufRead cvs\d\+                   setf cvs
2049 " WEB (*.web is also used for Winbatch: Guess, based on expecting "%" comment
2050 " lines in a WEB file).
2051 au BufNewFile,BufRead *.web
2052         \ if getline(1)[0].getline(2)[0].getline(3)[0].getline(4)[0].getline(5)[0] =~ "%" |
2053         \   setf web |
2054         \ else |
2055         \   setf winbatch |
2056         \ endif
2058 " Windows Scripting Host and Windows Script Component
2059 au BufNewFile,BufRead *.ws[fc]                  setf wsh
2061 " XHTML
2062 au BufNewFile,BufRead *.xhtml,*.xht             setf xhtml
2064 " X Pixmap (dynamically sets colors, use BufEnter to make it work better)
2065 au BufEnter *.xpm
2066         \ if getline(1) =~ "XPM2" |
2067         \   setf xpm2 |
2068         \ else |
2069         \   setf xpm |
2070         \ endif
2071 au BufEnter *.xpm2                              setf xpm2
2073 " XFree86 config
2074 au BufNewFile,BufRead XF86Config
2075         \ if getline(1) =~ '\<XConfigurator\>' |
2076         \   let b:xf86c_xfree86_version = 3 |
2077         \ endif |
2078         \ setf xf86conf
2080 " Xorg config
2081 au BufNewFile,BufRead xorg.conf,xorg.conf-4     let b:xf86c_xfree86_version = 4 | setf xf86conf
2083 " Xinetd conf
2084 au BufNewFile,BufRead /etc/xinetd.conf          setf xinetd
2086 " XS Perl extension interface language
2087 au BufNewFile,BufRead *.xs                      setf xs
2089 " X resources file
2090 au BufNewFile,BufRead .Xdefaults,.Xpdefaults,.Xresources,xdm-config,*.ad setf xdefaults
2092 " Xmath
2093 au BufNewFile,BufRead *.msc,*.msf               setf xmath
2094 au BufNewFile,BufRead *.ms
2095         \ if !s:FTnroff() | setf xmath | endif
2097 " XML  specific variants: docbk and xbl
2098 au BufNewFile,BufRead *.xml                     call s:FTxml()
2100 func! s:FTxml()
2101   let n = 1
2102   while n < 100 && n < line("$")
2103     let line = getline(n)
2104     if line =~ '<!DOCTYPE.*DocBook'
2105       let b:docbk_type = "xml"
2106       setf docbk
2107       return
2108     endif
2109     if line =~ 'xmlns:xbl="http://www.mozilla.org/xbl"'
2110       setf xbl
2111       return
2112     endif
2113     let n += 1
2114   endwhile
2115   setf xml
2116 endfunc
2118 " XMI (holding UML models) is also XML
2119 au BufNewFile,BufRead *.xmi                     setf xml
2121 " CSPROJ files are Visual Studio.NET's XML-based project config files
2122 au BufNewFile,BufRead *.csproj,*.csproj.user    setf xml
2124 " Qt Linguist translation source and Qt User Interface Files are XML
2125 au BufNewFile,BufRead *.ts,*.ui                 setf xml
2127 " TPM's are RDF-based descriptions of TeX packages (Nikolai Weibull)
2128 au BufNewFile,BufRead *.tpm                     setf xml
2130 " Xdg menus
2131 au BufNewFile,BufRead /etc/xdg/menus/*.menu     setf xml
2133 " ATI graphics driver configuration
2134 au BufNewFile,BufRead fglrxrc                   setf xml
2136 " XLIFF (XML Localisation Interchange File Format) is also XML
2137 au BufNewFile,BufRead *.xlf                     setf xml
2138 au BufNewFile,BufRead *.xliff                   setf xml
2140 " X11 xmodmap (also see below)
2141 au BufNewFile,BufRead *Xmodmap                  setf xmodmap
2143 " Xquery
2144 au BufNewFile,BufRead *.xq,*.xql,*.xqm,*.xquery,*.xqy   setf xquery
2146 " XSD
2147 au BufNewFile,BufRead *.xsd                     setf xsd
2149 " Xslt
2150 au BufNewFile,BufRead *.xsl,*.xslt              setf xslt
2152 " Yacc
2153 au BufNewFile,BufRead *.yy                      setf yacc
2155 " Yacc or racc
2156 au BufNewFile,BufRead *.y                       call s:FTy()
2158 func! s:FTy()
2159   let n = 1
2160   while n < 100 && n < line("$")
2161     let line = getline(n)
2162     if line =~ '^\s*%'
2163       setf yacc
2164       return
2165     endif
2166     if getline(n) =~ '^\s*\(#\|class\>\)' && getline(n) !~ '^\s*#\s*include'
2167       setf racc
2168       return
2169     endif
2170     let n = n + 1
2171   endwhile
2172   setf yacc
2173 endfunc
2176 " Yaml
2177 au BufNewFile,BufRead *.yaml,*.yml              setf yaml
2179 " Zope
2180 "   dtml (zope dynamic template markup language), pt (zope page template),
2181 "   cpt (zope form controller page template)
2182 au BufNewFile,BufRead *.dtml,*.pt,*.cpt         call s:FThtml()
2183 "   zsql (zope sql method)
2184 au BufNewFile,BufRead *.zsql                    call s:SQL()
2186 " Z80 assembler asz80
2187 au BufNewFile,BufRead *.z8a                     setf z8a
2189 augroup END
2192 " Source the user-specified filetype file, for backwards compatibility with
2193 " Vim 5.x.
2194 if exists("myfiletypefile") && filereadable(expand(myfiletypefile))
2195   execute "source " . myfiletypefile
2196 endif
2199 " Check for "*" after loading myfiletypefile, so that scripts.vim is only used
2200 " when there are no matching file name extensions.
2201 " Don't do this for compressed files.
2202 augroup filetypedetect
2203 au BufNewFile,BufRead *
2204         \ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
2205         \ | runtime! scripts.vim | endif
2206 au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif
2209 " Extra checks for when no filetype has been detected now.  Mostly used for
2210 " patterns that end in "*".  E.g., "zsh*" matches "zsh.vim", but that's a Vim
2211 " script file.
2212 " Most of these should call s:StarSetf() to avoid names ending in .gz and the
2213 " like are used.
2215 " Asterisk config file
2216 au BufNewFile,BufRead *asterisk/*.conf*         call s:StarSetf('asterisk')
2217 au BufNewFile,BufRead *asterisk*/*voicemail.conf* call s:StarSetf('asteriskvm')
2219 " Bazaar version control
2220 au BufNewFile,BufRead bzr_log.*                 setf bzr
2222 " BIND zone
2223 au BufNewFile,BufRead */named/db.*,*/bind/db.*  call s:StarSetf('bindzone')
2225 " Changelog
2226 au BufNewFile,BufRead [cC]hange[lL]og*
2227         \ if getline(1) =~ '; urgency='
2228         \|  call s:StarSetf('debchangelog')
2229         \|else
2230         \|  call s:StarSetf('changelog')
2231         \|endif
2233 " Crontab
2234 au BufNewFile,BufRead crontab,crontab.*         call s:StarSetf('crontab')
2236 " Debian Sources.list
2237 au BufNewFile,BufRead /etc/apt/sources.list.d/* call s:StarSetf('debsources')
2239 " Dracula
2240 au BufNewFile,BufRead drac.*                    call s:StarSetf('dracula')
2242 " Fvwm
2243 au BufNewFile,BufRead */.fvwm/*                 call s:StarSetf('fvwm')
2244 au BufNewFile,BufRead *fvwmrc*,*fvwm95*.hook
2245         \ let b:fvwm_version = 1 | call s:StarSetf('fvwm')
2246 au BufNewFile,BufRead *fvwm2rc*
2247         \ if expand("<afile>:e") == "m4"
2248         \|  call s:StarSetf('fvwm2m4')
2249         \|else
2250         \|  let b:fvwm_version = 2 | call s:StarSetf('fvwm')
2251         \|endif
2253 " GTK RC
2254 au BufNewFile,BufRead .gtkrc*,gtkrc*            call s:StarSetf('gtkrc')
2256 " Jam
2257 au BufNewFile,BufRead Prl*.*,JAM*.*             call s:StarSetf('jam')
2259 " Jargon
2260 au! BufNewFile,BufRead *jarg*
2261         \ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'THIS IS THE JARGON FILE'
2262         \|  call s:StarSetf('jargon')
2263         \|endif
2265 " Kconfig
2266 au BufNewFile,BufRead Kconfig.*                 call s:StarSetf('kconfig')
2268 " Makefile
2269 au BufNewFile,BufRead [mM]akefile*              call s:StarSetf('make')
2271 " Ruby Makefile
2272 au BufNewFile,BufRead [rR]akefile*              call s:StarSetf('ruby')
2274 " Mail (also matches muttrc.vim, so this is below the other checks)
2275 au BufNewFile,BufRead mutt[[:alnum:]._-]\{6\}   setf mail
2277 " Modconf
2278 au BufNewFile,BufRead /etc/modprobe.*           call s:StarSetf('modconf')
2280 " Mutt setup file
2281 au BufNewFile,BufRead .mutt{ng,}rc*,*/.mutt{ng,}/mutt{ng,}rc*   call s:StarSetf('muttrc')
2282 au BufNewFile,BufRead mutt{ng,}rc*,Mutt{ng,}rc*         call s:StarSetf('muttrc')
2284 " Nroff macros
2285 au BufNewFile,BufRead tmac.*                    call s:StarSetf('nroff')
2287 " Pam conf
2288 au BufNewFile,BufRead /etc/pam.d/*              call s:StarSetf('pamconf')
2290 " Printcap and Termcap
2291 au BufNewFile,BufRead *printcap*
2292         \ if !did_filetype()
2293         \|  let b:ptcap_type = "print" | call s:StarSetf('ptcap')
2294         \|endif
2295 au BufNewFile,BufRead *termcap*
2296         \ if !did_filetype()
2297         \|  let b:ptcap_type = "term" | call s:StarSetf('ptcap')
2298         \|endif
2300 " Vim script
2301 au BufNewFile,BufRead *vimrc*                   call s:StarSetf('vim')
2303 " Subversion commit file
2304 au BufNewFile,BufRead svn-commit*.tmp           setf svn
2306 " X resources file
2307 au BufNewFile,BufRead Xresources*,*/app-defaults/*,*/Xresources/* call s:StarSetf('xdefaults')
2309 " XFree86 config
2310 au BufNewFile,BufRead XF86Config-4*
2311         \ let b:xf86c_xfree86_version = 4 | call s:StarSetf('xf86conf')
2312 au BufNewFile,BufRead XF86Config*
2313         \ if getline(1) =~ '\<XConfigurator\>'
2314         \|  let b:xf86c_xfree86_version = 3
2315         \|endif
2316         \|call s:StarSetf('xf86conf')
2318 " X11 xmodmap
2319 au BufNewFile,BufRead *xmodmap*                 call s:StarSetf('xmodmap')
2321 " Xinetd conf
2322 au BufNewFile,BufRead /etc/xinetd.d/*           call s:StarSetf('xinetd')
2324 " Z-Shell script
2325 au BufNewFile,BufRead zsh*,zlog*                call s:StarSetf('zsh')
2328 " Generic configuration file (check this last, it's just guessing!)
2329 au BufNewFile,BufRead,StdinReadPost *
2330         \ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
2331         \    && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#'
2332         \       || getline(4) =~ '^#' || getline(5) =~ '^#') |
2333         \   setf conf |
2334         \ endif
2336 " Use the plugin-filetype checks last, they may overrule any of the previously
2337 " detected filetypes.
2338 runtime! ftdetect/*.vim
2340 augroup END
2343 " If the GUI is already running, may still need to install the Syntax menu.
2344 " Don't do it when the 'M' flag is included in 'guioptions'.
2345 if has("menu") && has("gui_running")
2346       \ && !exists("did_install_syntax_menu") && &guioptions !~# "M"
2347   source <sfile>:p:h/menu.vim
2348 endif
2350 " Function called for testing all functions defined here.  These are
2351 " script-local, thus need to be executed here.
2352 " Returns a string with error messages (hopefully empty).
2353 func! TestFiletypeFuncs(testlist)
2354   let output = ''
2355   for f in a:testlist
2356     try
2357       exe f
2358     catch
2359       let output = output . "\n" . f . ": " . v:exception
2360     endtry
2361   endfor
2362   return output
2363 endfunc
2365 " Restore 'cpoptions'
2366 let &cpo = s:cpo_save
2367 unlet s:cpo_save