Merged from the latest developing branch.
[MacVim.git] / runtime / filetype.vim
blobbe0e1cc59b3f8a10d264b9e2c30e910f91122330
1 " Vim support file to detect file types
3 " Maintainer:   Bram Moolenaar <Bram@vim.org>
4 " Last Change:  2007 May 15
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 if exists("*fnameescape")
20 au BufNewFile,BufRead ?\+.orig,?\+.bak,?\+.old,?\+.new,?\+.rpmsave,?\+.rpmnew
21         \ exe "doau filetypedetect BufRead " . fnameescape(expand("<afile>:r"))
22 au 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
29 au BufNewFile,BufRead ?\+.in
30         \ if expand("<afile>:t") != "configure.in" |
31         \   exe "doau filetypedetect BufRead " . fnameescape(expand("<afile>:r")) |
32         \ endif
33 elseif &verbose > 0
34   echomsg "Warning: some filetypes will not be recognized because this version of Vim does not have fnameescape()"
35 endif
37 " Pattern used to match file names which should not be inspected.
38 " Currently finds compressed files.
39 if !exists("g:ft_ignore_pat")
40   let g:ft_ignore_pat = '\.\(Z\|gz\|bz2\|zip\|tgz\)$'
41 endif
43 " Function used for patterns that end in a star: don't set the filetype if the
44 " file name matches ft_ignore_pat.
45 func! s:StarSetf(ft)
46   if expand("<amatch>") !~ g:ft_ignore_pat
47     exe 'setf ' . a:ft
48   endif
49 endfunc
51 " Abaqus or Trasys
52 au BufNewFile,BufRead *.inp                     call s:Check_inp()
54 func! s:Check_inp()
55   if getline(1) =~ '^\*'
56     setf abaqus
57   else
58     let n = 1
59     if line("$") > 500
60       let nmax = 500
61     else
62       let nmax = line("$")
63     endif
64     while n <= nmax
65       if getline(n) =~? "^header surface data"
66         setf trasys
67         break
68       endif
69       let n = n + 1
70     endwhile
71   endif
72 endfunc
74 " A-A-P recipe
75 au BufNewFile,BufRead *.aap                     setf aap
77 " A2ps printing utility
78 au BufNewFile,BufRead etc/a2ps.cfg,etc/a2ps/*.cfg,a2psrc,.a2psrc setf a2ps
80 " ABAB/4
81 au BufNewFile,BufRead *.abap                    setf abap
83 " ABC music notation
84 au BufNewFile,BufRead *.abc                     setf abc
86 " ABEL
87 au BufNewFile,BufRead *.abl                     setf abel
89 " AceDB
90 au BufNewFile,BufRead *.wrm                     setf acedb
92 " Ada (83, 9X, 95)
93 au BufNewFile,BufRead *.adb,*.ads,*.ada         setf ada
94 if has("vms")
95   au BufNewFile,BufRead *.gpr,*.ada_m,*.adc     setf ada
96 else
97   au BufNewFile,BufRead *.gpr                   setf ada
98 endif
100 " AHDL
101 au BufNewFile,BufRead *.tdf                     setf ahdl
103 " AMPL
104 au BufNewFile,BufRead *.run                     setf ampl
106 " Ant
107 au BufNewFile,BufRead build.xml                 setf ant
109 " Apache style config file
110 au BufNewFile,BufRead proftpd.conf*             call s:StarSetf('apachestyle')
112 " Apache config file
113 au BufNewFile,BufRead .htaccess                  setf apache
114 au BufNewFile,BufRead httpd.conf*,srm.conf*,access.conf*,apache.conf*,apache2.conf*,/etc/apache2/*.conf* call s:StarSetf('apache')
116 " XA65 MOS6510 cross assembler
117 au BufNewFile,BufRead *.a65                     setf a65
119 " Applix ELF
120 au BufNewFile,BufRead *.am
121         \ if expand("<afile>") !~? 'Makefile.am\>' | setf elf | endif
123 " ALSA configuration
124 au BufNewFile,BufRead ~/.asoundrc,/usr/share/alsa/alsa.conf,/etc/asound.conf    setf alsaconf
126 " Arc Macro Language
127 au BufNewFile,BufRead *.aml                     setf aml
129 " Arch Inventory file
130 au BufNewFile,BufRead .arch-inventory,=tagging-method   setf arch
132 " ART*Enterprise (formerly ART-IM)
133 au BufNewFile,BufRead *.art                     setf art
135 " ASN.1
136 au BufNewFile,BufRead *.asn,*.asn1              setf asn
138 " Active Server Pages (with Visual Basic Script)
139 au BufNewFile,BufRead *.asa
140         \ if exists("g:filetype_asa") |
141         \   exe "setf " . g:filetype_asa |
142         \ else |
143         \   setf aspvbs |
144         \ endif
146 " Active Server Pages (with Perl or Visual Basic Script)
147 au BufNewFile,BufRead *.asp
148         \ if exists("g:filetype_asp") |
149         \   exe "setf " . g:filetype_asp |
150         \ elseif getline(1) . getline(2) . getline(3) =~? "perlscript" |
151         \   setf aspperl |
152         \ else |
153         \   setf aspvbs |
154         \ endif
156 " Grub (must be before catch *.lst)
157 au BufNewFile,BufRead /boot/grub/menu.lst,/boot/grub/grub.conf,/etc/grub.conf   setf grub
159 " Assembly (all kinds)
160 " *.lst is not pure assembly, it has two extra columns (address, byte codes)
161 au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst   call s:FTasm()
163 " This function checks for the kind of assembly that is wanted by the user, or
164 " can be detected from the first five lines of the file.
165 func! s:FTasm()
166   " make sure b:asmsyntax exists
167   if !exists("b:asmsyntax")
168     let b:asmsyntax = ""
169   endif
171   if b:asmsyntax == ""
172     call s:FTasmsyntax()
173   endif
175   " if b:asmsyntax still isn't set, default to asmsyntax or GNU
176   if b:asmsyntax == ""
177     if exists("g:asmsyntax")
178       let b:asmsyntax = g:asmsyntax
179     else
180       let b:asmsyntax = "asm"
181     endif
182   endif
184   exe "setf " . b:asmsyntax
185 endfunc
187 func! s:FTasmsyntax()
188   " see if file contains any asmsyntax=foo overrides. If so, change
189   " b:asmsyntax appropriately
190   let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4).
191         \" ".getline(5)." "
192   if head =~ '\sasmsyntax=\S\+\s'
193     let b:asmsyntax = substitute(head, '.*\sasmsyntax=\([a-zA-Z0-9]\+\)\s.*','\1', "")
194   elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library'))
195     let b:asmsyntax = "vmasm"
196   endif
197 endfunc
199 " Macro (VAX)
200 au BufNewFile,BufRead *.mar                     setf vmasm
202 " Atlas
203 au BufNewFile,BufRead *.atl,*.as                setf atlas
205 " Autoit v3
206 au BufNewFile,BufRead *.au3                     setf autoit
208 " Autohotkey
209 au BufNewFile,BufRead *.ahk                     setf autohotkey
211 " Automake
212 au BufNewFile,BufRead [mM]akefile.am,GNUmakefile.am     setf automake
214 " Autotest .at files are actually m4
215 au BufNewFile,BufRead *.at                      setf m4
217 " Avenue
218 au BufNewFile,BufRead *.ave                     setf ave
220 " Awk
221 au BufNewFile,BufRead *.awk                     setf awk
223 " B
224 au BufNewFile,BufRead *.mch,*.ref,*.imp         setf b
226 " BASIC or Visual Basic
227 au BufNewFile,BufRead *.bas                     call s:FTVB("basic")
229 " Check if one of the first five lines contains "VB_Name".  In that case it is
230 " probably a Visual Basic file.  Otherwise it's assumed to be "alt" filetype.
231 func! s:FTVB(alt)
232   if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)'
233     setf vb
234   else
235     exe "setf " . a:alt
236   endif
237 endfunc
239 " Visual Basic Script (close to Visual Basic)
240 au BufNewFile,BufRead *.vbs,*.dsm,*.ctl         setf vb
242 " IBasic file (similar to QBasic)
243 au BufNewFile,BufRead *.iba,*.ibi               setf ibasic
245 " FreeBasic file (similar to QBasic)
246 au BufNewFile,BufRead *.fb,*.bi                 setf freebasic
248 " Batch file for MSDOS.
249 au BufNewFile,BufRead *.bat,*.sys               setf dosbatch
250 " *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd.
251 au BufNewFile,BufRead *.cmd
252         \ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif
254 " Batch file for 4DOS
255 au BufNewFile,BufRead *.btm                     call s:FTbtm()
256 func! s:FTbtm()
257   if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm
258     setf dosbatch
259   else
260     setf btm
261   endif
262 endfunc
264 " BC calculator
265 au BufNewFile,BufRead *.bc                      setf bc
267 " BDF font
268 au BufNewFile,BufRead *.bdf                     setf bdf
270 " BibTeX bibliography database file
271 au BufNewFile,BufRead *.bib                     setf bib
273 " BibTeX Bibliography Style
274 au BufNewFile,BufRead *.bst                     setf bst
276 " BIND configuration
277 au BufNewFile,BufRead named.conf,rndc.conf      setf named
279 " BIND zone
280 au BufNewFile,BufRead named.root                setf bindzone
281 au BufNewFile,BufRead *.db                      call s:BindzoneCheck('')
283 func! s:BindzoneCheck(default)
284   if getline(1).getline(2).getline(3).getline(4) =~ '^; <<>> DiG [0-9.]\+ <<>>\|BIND.*named\|$ORIGIN\|$TTL\|IN\s\+SOA'
285     setf bindzone
286   elseif a:default != ''
287     exe 'setf ' . a:default
288   endif
289 endfunc
291 " Blank
292 au BufNewFile,BufRead *.bl                      setf blank
294 " C or lpc
295 au BufNewFile,BufRead *.c                       call s:FTlpc()
297 func! s:FTlpc()
298   if exists("g:lpc_syntax_for_c")
299     let lnum = 1
300     while lnum <= 12
301       if getline(lnum) =~# '^\(//\|inherit\|private\|protected\|nosave\|string\|object\|mapping\|mixed\)'
302         setf lpc
303         return
304       endif
305       let lnum = lnum + 1
306     endwhile
307   endif
308   setf c
309 endfunc
311 " Calendar
312 au BufNewFile,BufRead calendar                  setf calendar
313 au BufNewFile,BufRead */.calendar/*,
314         \*/share/calendar/*/calendar.*,*/share/calendar/calendar.*
315         \                                       call s:StarSetf('calendar')
317 " C#
318 au BufNewFile,BufRead *.cs                      setf cs
320 " Cdrdao TOC
321 au BufNewFile,BufRead *.toc                     setf cdrtoc
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 or C++, set c_syntax_for_h if you want C,
353 " ch_syntax_for_h if you want Ch.
354 au BufNewFile,BufRead *.h
355         \ if exists("c_syntax_for_h") | setf c |
356         \ elseif exists("ch_syntax_for_h") | setf ch |
357         \ else | setf cpp | endif
359 " Ch (CHscript)
360 au BufNewFile,BufRead *.chf                     setf ch
362 " TLH files are C++ headers generated by Visual C++'s #import from typelibs
363 au BufNewFile,BufRead *.tlh                     setf cpp
365 " Cascading Style Sheets
366 au BufNewFile,BufRead *.css                     setf css
368 " Century Term Command Scripts (*.cmd too)
369 au BufNewFile,BufRead *.con                     setf cterm
371 " Changelog
372 au BufNewFile,BufRead changelog.Debian,changelog.dch,NEWS.Debian,NEWS.dch
373                                         \       setf debchangelog
375 au BufNewFile,BufRead [cC]hange[lL]og
376         \  if getline(1) =~ '; urgency='
377         \|   setf debchangelog
378         \| else
379         \|   setf changelog
380         \| endif
382 au BufNewFile,BufRead NEWS
383         \  if getline(1) =~ '; urgency='
384         \|   setf debchangelog
385         \| endif
387 " CHILL
388 au BufNewFile,BufRead *..ch                     setf chill
390 " Changes for WEB and CWEB or CHILL
391 au BufNewFile,BufRead *.ch                      call s:FTchange()
393 " This function checks if one of the first ten lines start with a '@'.  In
394 " that case it is probably a change file.
395 " If the first line starts with # or ! it's probably a ch file.
396 " If a line has "main", "include", "//" ir "/*" it's probably ch.
397 " Otherwise CHILL is assumed.
398 func! s:FTchange()
399   let lnum = 1
400   while lnum <= 10
401     if getline(lnum)[0] == '@'
402       setf change
403       return
404     endif
405     if lnum == 1 && (getline(1)[0] == '#' || getline(1)[0] == '!')
406       setf ch
407       return
408     endif
409     if getline(lnum) =~ "MODULE"
410       setf chill
411       return
412     endif
413     if getline(lnum) =~ 'main\s*(\|#\s*include\|//'
414       setf ch
415       return
416     endif
417     let lnum = lnum + 1
418   endwhile
419   setf chill
420 endfunc
422 " ChordPro
423 au BufNewFile,BufRead *.chopro,*.crd,*.cho,*.crdpro,*.chordpro  setf chordpro
425 " Clean
426 au BufNewFile,BufRead *.dcl,*.icl               setf clean
428 " Clever
429 au BufNewFile,BufRead *.eni                     setf cl
431 " Clever or dtd
432 au BufNewFile,BufRead *.ent                     call s:FTent()
434 func! s:FTent()
435   " This function checks for valid cl syntax in the first five lines.
436   " Look for either an opening comment, '#', or a block start, '{".
437   " If not found, assume SGML.
438   let lnum = 1
439   while lnum < 6
440     let line = getline(lnum)
441     if line =~ '^\s*[#{]'
442       setf cl
443       return
444     elseif line !~ '^\s*$'
445       " Not a blank line, not a comment, and not a block start,
446       " so doesn't look like valid cl code.
447       break
448     endif
449     let lnum = lnum + 1
450   endw
451   setf dtd
452 endfunc
454 " Clipper (or FoxPro; could also be eviews)
455 au BufNewFile,BufRead *.prg
456         \ if exists("g:filetype_prg") |
457         \   exe "setf " . g:filetype_prg |
458         \ else |
459         \   setf clipper |
460         \ endif
462 " Cmake
463 au BufNewFile,BufRead CMakeLists.txt,*.cmake,*.cmake.in         setf cmake
465 " Cmusrc
466 au BufNewFile,BufRead ~/.cmus/{autosave,rc,command-history,*.theme} setf cmusrc
467 au BufNewFile,BufRead */cmus/{rc,*.theme}                       setf cmusrc
469 " Cobol
470 au BufNewFile,BufRead *.cbl,*.cob,*.lib setf cobol
471 "   cobol or zope form controller python script? (heuristic)
472 au BufNewFile,BufRead *.cpy
473         \ if getline(1) =~ '^##' |
474         \   setf python |
475         \ else |
476         \   setf cobol |
477         \ endif
479 " Cold Fusion
480 au BufNewFile,BufRead *.cfm,*.cfi,*.cfc         setf cf
482 " Configure scripts
483 au BufNewFile,BufRead configure.in,configure.ac setf config
485 " WildPackets EtherPeek Decoder
486 au BufNewFile,BufRead *.dcd                     setf dcd
488 " Enlightenment configuration files
489 au BufNewFile,BufRead *enlightenment/*.cfg      setf c
491 " Eterm
492 au BufNewFile,BufRead *Eterm/*.cfg              setf eterm
494 " Lynx config files
495 au BufNewFile,BufRead lynx.cfg                  setf lynx
497 " Quake
498 au BufNewFile,BufRead *baseq[2-3]/*.cfg,*id1/*.cfg      setf quake
499 au BufNewFile,BufRead *quake[1-3]/*.cfg                 setf quake
501 " Quake C
502 au BufNewFile,BufRead *.qc                      setf c
504 " Configure files
505 au BufNewFile,BufRead *.cfg                     setf cfg
507 " Communicating Sequential Processes
508 au BufNewFile,BufRead *.csp,*.fdr               setf csp
510 " CUPL logic description and simulation
511 au BufNewFile,BufRead *.pld                     setf cupl
512 au BufNewFile,BufRead *.si                      setf cuplsim
514 " Debian Control
515 au BufNewFile,BufRead */debian/control          setf debcontrol
517 " Debian Sources.list
518 au BufNewFile,BufRead /etc/apt/sources.list     setf debsources
520 " ROCKLinux package description
521 au BufNewFile,BufRead *.desc                    setf desc
523 " the D language
524 au BufNewFile,BufRead *.d                       setf d
526 " Desktop files
527 au BufNewFile,BufRead *.desktop,.directory      setf desktop
529 " Dict config
530 au BufNewFile,BufRead dict.conf,.dictrc         setf dictconf
532 " Dictd config
533 au BufNewFile,BufRead dictd.conf                setf dictdconf
535 " Diff files
536 au BufNewFile,BufRead *.diff,*.rej,*.patch      setf diff
538 " Dircolors
539 au BufNewFile,BufRead .dir_colors,/etc/DIR_COLORS       setf dircolors
541 " Diva (with Skill) or InstallShield
542 au BufNewFile,BufRead *.rul
543         \ if getline(1).getline(2).getline(3).getline(4).getline(5).getline(6) =~? 'InstallShield' |
544         \   setf ishd |
545         \ else |
546         \   setf diva |
547         \ endif
549 " DCL (Digital Command Language - vms) or DNS zone file
550 au BufNewFile,BufRead *.com                     call s:BindzoneCheck('dcl')
552 " DOT
553 au BufNewFile,BufRead *.dot                     setf dot
555 " Dylan - lid files
556 au BufNewFile,BufRead *.lid                     setf dylanlid
558 " Dylan - intr files (melange)
559 au BufNewFile,BufRead *.intr                    setf dylanintr
561 " Dylan
562 au BufNewFile,BufRead *.dylan                   setf dylan
564 " Microsoft Module Definition
565 au BufNewFile,BufRead *.def                     setf def
567 " Dracula
568 au BufNewFile,BufRead *.drac,*.drc,*lvs,*lpe    setf dracula
570 " dsl
571 au BufNewFile,BufRead *.dsl                     setf dsl
573 " DTD (Document Type Definition for XML)
574 au BufNewFile,BufRead *.dtd                     setf dtd
576 " EDIF (*.edf,*.edif,*.edn,*.edo)
577 au BufNewFile,BufRead *.ed\(f\|if\|n\|o\)       setf edif
579 " Embedix Component Description
580 au BufNewFile,BufRead *.ecd                     setf ecd
582 " Eiffel or Specman
583 au BufNewFile,BufRead *.e,*.E                   call s:FTe()
585 " Elinks configuration
586 au BufNewFile,BufRead */etc/elinks.conf,*/.elinks/elinks.conf   setf elinks
588 func! s:FTe()
589   let n = 1
590   while n < 100 && n < line("$")
591     if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$"
592       setf specman
593       return
594     endif
595     let n = n + 1
596   endwhile
597   setf eiffel
598 endfunc
600 " ERicsson LANGuage
601 au BufNewFile,BufRead *.erl                     setf erlang
603 " Elm Filter Rules file
604 au BufNewFile,BufRead filter-rules              setf elmfilt
606 " ESMTP rc file
607 au BufNewFile,BufRead *esmtprc                  setf esmtprc
609 " ESQL-C
610 au BufNewFile,BufRead *.ec,*.EC                 setf esqlc
612 " Esterel
613 au BufNewFile,BufRead *.strl                    setf esterel
615 " Essbase script
616 au BufNewFile,BufRead *.csc                     setf csc
618 " Exim
619 au BufNewFile,BufRead exim.conf                 setf exim
621 " Expect
622 au BufNewFile,BufRead *.exp                     setf expect
624 " Exports
625 au BufNewFile,BufRead exports                   setf exports
627 " Factor
628 au BufNewFile,BufRead *.factor                  setf factor
630 " Fetchmail RC file
631 au BufNewFile,BufRead .fetchmailrc              setf fetchmail
633 " FlexWiki
634 au BufNewFile,BufRead *.wiki                    setf flexwiki
636 " Focus Executable
637 au BufNewFile,BufRead *.fex,*.focexec           setf focexec
639 " Focus Master file (but not for auto.master)
640 au BufNewFile,BufRead auto.master               setf conf
641 au BufNewFile,BufRead *.mas,*.master            setf master
643 " Forth
644 au BufNewFile,BufRead *.fs,*.ft                 setf forth
646 " Fortran
647 if has("fname_case")
648   au BufNewFile,BufRead *.F,*.FOR,*.FPP,*.FTN,*.F77,*.F90,*.F95  setf fortran
649 endif
650 au BufNewFile,BufRead   *.f,*.for,*.fpp,*.ftn,*.f77,*.f90,*.f95  setf fortran
652 " FStab
653 au BufNewFile,BufRead fstab,mtab                setf fstab
655 " GDB command files
656 au BufNewFile,BufRead .gdbinit                  setf gdb
658 " GDMO
659 au BufNewFile,BufRead *.mo,*.gdmo               setf gdmo
661 " Gedcom
662 au BufNewFile,BufRead *.ged                     setf gedcom
664 " Gkrellmrc
665 au BufNewFile,BufRead gkrellmrc,gkrellmrc_?     setf gkrellmrc
667 " GP scripts (2.0 and onward)
668 au BufNewFile,BufRead *.gp,.gprc                setf gp
670 " GPG
671 au BufNewFile,BufRead */.gnupg/options          setf gpg
672 au BufNewFile,BufRead */.gnupg/gpg.conf         setf gpg
673 au BufNewFile,BufRead /usr/**/gnupg/options.skel setf gpg
675 " Gnuplot scripts
676 au BufNewFile,BufRead *.gpi                     setf gnuplot
678 " GrADS scripts
679 au BufNewFile,BufRead *.gs                      setf grads
681 " Gretl
682 au BufNewFile,BufRead *.gretl                   setf gretl
684 " Groovy
685 au BufNewFile,BufRead *.groovy                  setf groovy
687 " GNU Server Pages
688 au BufNewFile,BufRead *.gsp                     setf gsp
690 " Group file
691 au BufNewFile,BufRead /etc/group                setf group
693 " GTK RC
694 au BufNewFile,BufRead .gtkrc,gtkrc              setf gtkrc
696 " Hamster Classic | Playground files
697 au BufNewFile,BufRead *.hsc,*.hsm               setf hamster
699 " Haskell
700 au BufNewFile,BufRead *.hs                      setf haskell
701 au BufNewFile,BufRead *.lhs                     setf lhaskell
702 au BufNewFile,BufRead *.chs                     setf chaskell
704 " Hercules
705 au BufNewFile,BufRead *.vc,*.ev,*.rs,*.sum,*.errsum     setf hercules
707 " HEX (Intel)
708 au BufNewFile,BufRead *.hex,*.h32               setf hex
710 " Tilde (must be before HTML)
711 au BufNewFile,BufRead *.t.html                  setf tilde
713 " HTML (.shtml and .stm for server side)
714 au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm  call s:FThtml()
716 " Distinguish between HTML, XHTML and Django
717 func! s:FThtml()
718   let n = 1
719   while n < 10 && n < line("$")
720     if getline(n) =~ '\<DTD\s\+XHTML\s'
721       setf xhtml
722       return
723     endif
724     if getline(n) =~ '{%\s*\(extends\|block\)\>'
725       setf htmldjango
726       return
727     endif
728     let n = n + 1
729   endwhile
730   setf html
731 endfunc
733 " HTML with Ruby - eRuby
734 au BufNewFile,BufRead *.erb,*.rhtml             setf eruby
736 " HTML with M4
737 au BufNewFile,BufRead *.html.m4                 setf htmlm4
739 " HTML Cheetah template
740 au BufNewFile,BufRead *.tmpl                    setf htmlcheetah
742 " Hyper Builder
743 au BufNewFile,BufRead *.hb                      setf hb
745 " Icon
746 au BufNewFile,BufRead *.icn                     setf icon
748 " IDL (Interface Description Language)
749 au BufNewFile,BufRead *.idl                     call s:FTidl()
751 " Distinguish between standard IDL and MS-IDL
752 func! s:FTidl()
753   let n = 1
754   while n < 50 && n < line("$")
755     if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"'
756       setf msidl
757       return
758     endif
759     let n = n + 1
760   endwhile
761   setf idl
762 endfunc
764 " Microsoft IDL (Interface Description Language)  Also *.idl
765 " MOF = WMI (Windows Management Instrumentation) Managed Object Format
766 au BufNewFile,BufRead *.odl,*.mof               setf msidl
768 " Icewm menu
769 au BufNewFile,BufRead */.icewm/menu             setf icemenu
771 " Indent profile (must come before IDL *.pro!)
772 au BufNewFile,BufRead .indent.pro               setf indent
773 au BufNewFile,BufRead indent.pro                call s:ProtoCheck('indent')
775 " IDL (Interactive Data Language)
776 au BufNewFile,BufRead *.pro                     call s:ProtoCheck('idlang')
778 " Distinguish between "default" and Cproto prototype file. */
779 func! s:ProtoCheck(default)
780   " Cproto files have a comment in the first line and a function prototype in
781   " the second line, it always ends in ";".  Indent files may also have
782   " comments, thus we can't match comments to see the difference.
783   if getline(2) =~ ';$'
784     setf cpp
785   else
786     exe 'setf ' . a:default
787   endif
788 endfunc
791 " Indent RC
792 au BufNewFile,BufRead indentrc                  setf indentrc
794 " Inform
795 au BufNewFile,BufRead *.inf,*.INF               setf inform
797 " Initng
798 au BufNewFile,BufRead /etc/initng/**/*.i,*.ii   setf initng
800 " Ipfilter
801 au BufNewFile,BufRead ipf.conf,ipf6.conf,ipf.rules      setf ipfilter
803 " Informix 4GL (source - canonical, include file, I4GL+M4 preproc.)
804 au BufNewFile,BufRead *.4gl,*.4gh,*.m4gl        setf fgl
806 " .INI file for MSDOS
807 au BufNewFile,BufRead *.ini                     setf dosini
809 " SysV Inittab
810 au BufNewFile,BufRead inittab                   setf inittab
812 " Inno Setup
813 au BufNewFile,BufRead *.iss                     setf iss
815 " JAL
816 au BufNewFile,BufRead *.jal,*.JAL               setf jal
818 " Jam
819 au BufNewFile,BufRead *.jpl,*.jpr               setf jam
821 " Java
822 au BufNewFile,BufRead *.java,*.jav              setf java
824 " JavaCC
825 au BufNewFile,BufRead *.jj,*.jjt                setf javacc
827 " JavaScript, ECMAScript
828 au BufNewFile,BufRead *.js,*.javascript,*.es    setf javascript
830 " Java Server Pages
831 au BufNewFile,BufRead *.jsp                     setf jsp
833 " Java Properties resource file (note: doesn't catch font.properties.pl)
834 au BufNewFile,BufRead *.properties,*.properties_??,*.properties_??_??   setf jproperties
835 au BufNewFile,BufRead *.properties_??_??_*      call s:StarSetf('jproperties')
837 " Jess
838 au BufNewFile,BufRead *.clp                     setf jess
840 " Jgraph
841 au BufNewFile,BufRead *.jgr                     setf jgraph
843 " Kixtart
844 au BufNewFile,BufRead *.kix                     setf kix
846 " Kimwitu[++]
847 au BufNewFile,BufRead *.k                       setf kwt
849 " KDE script
850 au BufNewFile,BufRead *.ks                      setf kscript
852 " Kconfig
853 au BufNewFile,BufRead Kconfig,Kconfig.debug     setf kconfig
855 " Lace (ISE)
856 au BufNewFile,BufRead *.ace,*.ACE               setf lace
858 " Latte
859 au BufNewFile,BufRead *.latte,*.lte             setf latte
861 " Limits
862 au BufNewFile,BufRead /etc/limits               setf limits
864 " LambdaProlog (*.mod too, see Modsim)
865 au BufNewFile,BufRead *.sig                     setf lprolog
867 " LDAP LDIF
868 au BufNewFile,BufRead *.ldif                    setf ldif
870 " Ld loader
871 au BufNewFile,BufRead *.ld                      setf ld
873 " Lex
874 au BufNewFile,BufRead *.lex,*.l                 setf lex
876 " Libao
877 au BufNewFile,BufRead /etc/libao.conf,*/.libao  setf libao
879 " Libsensors
880 au BufNewFile,BufRead /etc/sensors.conf         setf sensors
882 " LFTP
883 au BufNewFile,BufRead lftp.conf,.lftprc,*lftp/rc        setf lftp
885 " Lifelines (or Lex for C++!)
886 au BufNewFile,BufRead *.ll                      setf lifelines
888 " Lilo: Linux loader
889 au BufNewFile,BufRead lilo.conf*                call s:StarSetf('lilo')
891 " Lisp (*.el = ELisp, *.cl = Common Lisp, *.jl = librep Lisp)
892 if has("fname_case")
893   au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,*.L,.emacs,.sawfishrc setf lisp
894 else
895   au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,.emacs,.sawfishrc setf lisp
896 endif
898 " SBCL implementation of Common Lisp
899 au BufNewFile,BufRead sbclrc,.sbclrc            setf lisp
901 " Lite
902 au BufNewFile,BufRead *.lite,*.lt               setf lite
904 " LiteStep RC files
905 au BufNewFile,BufRead */LiteStep/*/*.rc         setf litestep
907 " Login access
908 au BufNewFile,BufRead /etc/login.access         setf loginaccess
910 " Login defs
911 au BufNewFile,BufRead /etc/login.defs           setf logindefs
913 " Logtalk
914 au BufNewFile,BufRead *.lgt                     setf logtalk
916 " LOTOS
917 au BufNewFile,BufRead *.lot,*.lotos             setf lotos
919 " Lout (also: *.lt)
920 au BufNewFile,BufRead *.lou,*.lout              setf lout
922 " Lua
923 au BufNewFile,BufRead *.lua                     setf lua
925 " Lynx style file (or LotusScript!)
926 au BufNewFile,BufRead *.lss                     setf lss
928 " M4
929 au BufNewFile,BufRead *.m4
930         \ if expand("<afile>") !~? 'html.m4$\|fvwm2rc' | setf m4 | endif
932 " MaGic Point
933 au BufNewFile,BufRead *.mgp                     setf mgp
935 " Mail (for Elm, trn, mutt, muttng, rn, slrn)
936 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
938 " Mail aliases
939 au BufNewFile,BufRead /etc/mail/aliases,/etc/aliases    setf mailaliases
941 " Mailcap configuration file
942 au BufNewFile,BufRead .mailcap,mailcap          setf mailcap
944 " Makefile
945 au BufNewFile,BufRead *[mM]akefile,*.mk,*.mak,*.dsp setf make
947 " MakeIndex
948 au BufNewFile,BufRead *.ist,*.mst               setf ist
950 " Manpage
951 au BufNewFile,BufRead *.man                     setf man
953 " Man config
954 au BufNewFile,BufRead /etc/man.conf,man.config  setf manconf
956 " Maple V
957 au BufNewFile,BufRead *.mv,*.mpl,*.mws          setf maple
959 " Mason
960 au BufNewFile,BufRead *.mason,*.mhtml           setf mason
962 " Matlab or Objective C
963 au BufNewFile,BufRead *.m                       call s:FTm()
965 func! s:FTm()
966   let n = 1
967   while n < 10
968     let line = getline(n)
969     if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)'
970       setf objc
971       return
972     endif
973     if line =~ '^\s*%'
974       setf matlab
975       return
976     endif
977     if line =~ '^\s*(\*'
978       setf mma
979       return
980     endif
981     let n = n + 1
982   endwhile
983   if exists("g:filetype_m")
984     exe "setf " . g:filetype_m
985   else
986     setf matlab
987   endif
988 endfunc
990 " Maya Extension Language
991 au BufNewFile,BufRead *.mel                     setf mel
993 " Messages
994 au BufNewFile,BufRead /var/log/messages,/var/log/messages.*[0-9]  setf messages
996 " Metafont
997 au BufNewFile,BufRead *.mf                      setf mf
999 " MetaPost
1000 au BufNewFile,BufRead *.mp                      setf mp
1002 " MGL
1003 au BufNewFile,BufRead *.mgl                     setf mgl
1005 " MMIX or VMS makefile
1006 au BufNewFile,BufRead *.mms                     call s:FTmms()
1008 func! s:FTmms()
1009   let n = 1
1010   while n < 10
1011     let line = getline(n)
1012     if line =~ '^\s*\(%\|//\)' || line =~ '^\*'
1013       setf mmix
1014       return
1015     endif
1016     if line =~ '^\s*#'
1017       setf make
1018       return
1019     endif
1020     let n = n + 1
1021   endwhile
1022   setf mmix
1023 endfunc
1026 " Modsim III (or LambdaProlog)
1027 au BufNewFile,BufRead *.mod
1028         \ if getline(1) =~ '\<module\>' |
1029         \   setf lprolog |
1030         \ else |
1031         \   setf modsim3 |
1032         \ endif
1034 " Modula 2
1035 au BufNewFile,BufRead *.m2,*.DEF,*.MOD,*.md,*.mi setf modula2
1037 " Modula 3 (.m3, .i3, .mg, .ig)
1038 au BufNewFile,BufRead *.[mi][3g]                setf modula3
1040 " Monk
1041 au BufNewFile,BufRead *.isc,*.monk,*.ssc,*.tsc  setf monk
1043 " MOO
1044 au BufNewFile,BufRead *.moo                     setf moo
1046 " Modconf
1047 au BufNewFile,BufRead /etc/modules.conf,/etc/conf.modules       setf modconf
1048 au BufNewFile,BufRead /etc/modutils/*
1049         \ if executable(expand("<afile>")) != 1
1050         \|  call s:StarSetf('modconf')
1051         \|endif
1053 " Mplayer config
1054 au BufNewFile,BufRead mplayer.conf,*/.mplayer/config    setf mplayerconf
1056 " Moterola S record
1057 au BufNewFile,BufRead *.s19,*.s28,*.s37         setf srec
1059 " Mrxvtrc
1060 au BufNewFile,BufRead mrxvtrc,.mrxvtrc          setf mrxvtrc
1062 " Msql
1063 au BufNewFile,BufRead *.msql                    setf msql
1065 " Mysql
1066 au BufNewFile,BufRead *.mysql                   setf mysql
1068 " M$ Resource files
1069 au BufNewFile,BufRead *.rc                      setf rc
1071 " MuPAD source
1072 au BufRead,BufNewFile *.mu                      setf mupad
1074 " Mush
1075 au BufNewFile,BufRead *.mush                    setf mush
1077 " Mutt setup file (also for Muttng)
1078 au BufNewFile,BufRead Mutt{ng,}rc                       setf muttrc
1079 au BufNewFile,BufRead .mutt{ng,}rc*,*/.mutt{ng,}/mutt{ng,}rc*   call s:StarSetf('muttrc')
1081 " Nano
1082 au BufNewFile,BufRead /etc/nanorc,.nanorc       setf nanorc
1084 " Nastran input/DMAP
1085 "au BufNewFile,BufRead *.dat                    setf nastran
1087 " Natural
1088 au BufNewFile,BufRead *.NS[ACGLMNPS]            setf natural
1090 " Netrc
1091 au BufNewFile,BufRead .netrc                    setf netrc
1093 " Novell netware batch files
1094 au BufNewFile,BufRead *.ncf                     setf ncf
1096 " Nroff/Troff (*.ms and *.t are checked below)
1097 au BufNewFile,BufRead *.me
1098         \ if expand("<afile>") != "read.me" && expand("<afile>") != "click.me" |
1099         \   setf nroff |
1100         \ endif
1101 au BufNewFile,BufRead *.tr,*.nr,*.roff,*.tmac,*.mom     setf nroff
1102 au BufNewFile,BufRead *.[1-9]                   call s:FTnroff()
1104 " This function checks if one of the first five lines start with a dot.  In
1105 " that case it is probably an nroff file: 'filetype' is set and 1 is returned.
1106 func! s:FTnroff()
1107   if getline(1)[0] . getline(2)[0] . getline(3)[0] . getline(4)[0] . getline(5)[0] =~ '\.'
1108     setf nroff
1109     return 1
1110   endif
1111   return 0
1112 endfunc
1114 " Nroff or Objective C++
1115 au BufNewFile,BufRead *.mm                      call s:FTmm()
1117 func! s:FTmm()
1118   let n = 1
1119   while n < 10
1120     let line = getline(n)
1121     if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)'
1122       setf objcpp
1123       return
1124     endif
1125     let n = n + 1
1126   endwhile
1127   setf nroff
1128 endfunc
1130 " Not Quite C
1131 au BufNewFile,BufRead *.nqc                     setf nqc
1133 " NSIS
1134 au BufNewFile,BufRead *.nsi                     setf nsis
1136 " OCAML
1137 au BufNewFile,BufRead *.ml,*.mli,*.mll,*.mly    setf ocaml
1139 " Occam
1140 au BufNewFile,BufRead *.occ                     setf occam
1142 " Omnimark
1143 au BufNewFile,BufRead *.xom,*.xin               setf omnimark
1145 " OpenROAD
1146 au BufNewFile,BufRead *.or                      setf openroad
1148 " OPL
1149 au BufNewFile,BufRead *.[Oo][Pp][Ll]            setf opl
1151 " Oracle config file
1152 au BufNewFile,BufRead *.ora                     setf ora
1154 " Packet filter conf
1155 au BufNewFile,BufRead pf.conf                   setf pf
1157 " Pam conf
1158 au BufNewFile,BufRead /etc/pam.conf             setf pamconf
1160 " PApp
1161 au BufNewFile,BufRead *.papp,*.pxml,*.pxsl      setf papp
1163 " Password file
1164 au BufNewFile,BufRead /etc/passwd,/etc/shadow,/etc/shadow- setf passwd
1166 " Pascal (also *.p)
1167 au BufNewFile,BufRead *.pas                     setf pascal
1169 " Delphi project file
1170 au BufNewFile,BufRead *.dpr                     setf pascal
1172 " Perl
1173 if has("fname_case")
1174   au BufNewFile,BufRead *.pl,*.PL               call s:FTpl()
1175 else
1176   au BufNewFile,BufRead *.pl                    call s:FTpl()
1177 endif
1178 au BufNewFile,BufRead *.plx                     setf perl
1180 func! s:FTpl()
1181   if exists("g:filetype_pl")
1182     exe "setf " . g:filetype_pl
1183   else
1184     " recognize Prolog by specific text in the first non-empty line
1185     " require a blank after the '%' because Perl uses "%list" and "%translate"
1186     let l = getline(nextnonblank(1))
1187     if l =~ '\<prolog\>' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-'
1188       setf prolog
1189     else
1190       setf perl
1191     endif
1192   endif
1193 endfunc
1195 " Perl, XPM or XPM2
1196 au BufNewFile,BufRead *.pm
1197         \ if getline(1) =~ "XPM2" |
1198         \   setf xpm2 |
1199         \ elseif getline(1) =~ "XPM" |
1200         \   setf xpm |
1201         \ else |
1202         \   setf perl |
1203         \ endif
1205 " Perl POD
1206 au BufNewFile,BufRead *.pod                     setf pod
1208 " Php, php3, php4, etc.
1209 au BufNewFile,BufRead *.php,*.php\d             setf php
1211 " Phtml
1212 au BufNewFile,BufRead *.phtml                   setf phtml
1214 " Pike
1215 au BufNewFile,BufRead *.pike,*.lpc,*.ulpc,*.pmod setf pike
1217 " Pinfo config
1218 au BufNewFile,BufRead */etc/pinforc,*/.pinforc  setf pinfo
1220 " Palm Resource compiler
1221 au BufNewFile,BufRead *.rcp                     setf pilrc
1223 " Pine config
1224 au BufNewFile,BufRead .pinerc,pinerc,.pinercex,pinercex         setf pine
1226 " PL/M (also: *.inp)
1227 au BufNewFile,BufRead *.plm,*.p36,*.pac         setf plm
1229 " PL/SQL
1230 au BufNewFile,BufRead *.pls,*.plsql             setf plsql
1232 " PLP
1233 au BufNewFile,BufRead *.plp                     setf plp
1235 " PO and PO template (GNU gettext)
1236 au BufNewFile,BufRead *.po,*.pot                setf po
1238 " Postfix main config
1239 au BufNewFile,BufRead main.cf                   setf pfmain
1241 " PostScript (+ font files, encapsulated PostScript, Adobe Illustrator)
1242 au BufNewFile,BufRead *.ps,*.pfa,*.afm,*.eps,*.epsf,*.epsi,*.ai   setf postscr
1244 " PostScript Printer Description
1245 au BufNewFile,BufRead *.ppd                     setf ppd
1247 " Povray
1248 au BufNewFile,BufRead *.pov                     setf pov
1250 " Povray configuration
1251 au BufNewFile,BufRead .povrayrc                 setf povini
1253 " Povray, PHP or assembly
1254 au BufNewFile,BufRead *.inc                     call s:FTinc()
1256 func! s:FTinc()
1257   if exists("g:filetype_inc")
1258     exe "setf " . g:filetype_inc
1259   else
1260     let lines = getline(1).getline(2).getline(3)
1261     if lines =~? "perlscript"
1262       setf aspperl
1263     elseif lines =~ "<%"
1264       setf aspvbs
1265     elseif lines =~ "<?"
1266       setf php
1267     else
1268       call s:FTasmsyntax()
1269       if exists("b:asmsyntax")
1270         exe "setf " . b:asmsyntax
1271       else
1272         setf pov
1273       endif
1274     endif
1275   endif
1276 endfunc
1278 " Printcap and Termcap
1279 au BufNewFile,BufRead *printcap
1280         \ let b:ptcap_type = "print" | setf ptcap
1281 au BufNewFile,BufRead *termcap
1282         \ let b:ptcap_type = "term" | setf ptcap
1284 " PCCTS / ANTRL
1285 "au BufNewFile,BufRead *.g                      setf antrl
1286 au BufNewFile,BufRead *.g                       setf pccts
1288 " PPWizard
1289 au BufNewFile,BufRead *.it,*.ih                 setf ppwiz
1291 " Oracle Pro*C/C++
1292 au BufNewFile,BufRead *.pc                      setf proc
1294 " Privoxy actions file
1295 au BufNewFile,BufRead *.action                  setf privoxy
1297 " Procmail
1298 au BufNewFile,BufRead .procmail,.procmailrc     setf procmail
1300 " Progress or CWEB
1301 au BufNewFile,BufRead *.w                       call s:FTprogress_cweb()
1303 func! s:FTprogress_cweb()
1304   if exists("g:filetype_w")
1305     exe "setf " . g:filetype_w
1306     return
1307   endif
1308   if getline(1) =~ '&ANALYZE' || getline(3) =~ '&GLOBAL-DEFINE'
1309     setf progress
1310   else
1311     setf cweb
1312   endif
1313 endfunc
1315 " Progress or assembly
1316 au BufNewFile,BufRead *.i                       call s:FTprogress_asm()
1318 func! s:FTprogress_asm()
1319   if exists("g:filetype_i")
1320     exe "setf " . g:filetype_i
1321     return
1322   endif
1323   " This function checks for an assembly comment the first ten lines.
1324   " If not found, assume Progress.
1325   let lnum = 1
1326   while lnum <= 10 && lnum < line('$')
1327     let line = getline(lnum)
1328     if line =~ '^\s*;' || line =~ '^\*'
1329       call s:FTasm()
1330       return
1331     elseif line !~ '^\s*$' || line =~ '^/\*'
1332       " Not an empty line: Doesn't look like valid assembly code.
1333       " Or it looks like a Progress /* comment
1334       break
1335     endif
1336     let lnum = lnum + 1
1337   endw
1338   setf progress
1339 endfunc
1341 " Progress or Pascal
1342 au BufNewFile,BufRead *.p                       call s:FTprogress_pascal()
1344 func! s:FTprogress_pascal()
1345   if exists("g:filetype_p")
1346     exe "setf " . g:filetype_p
1347     return
1348   endif
1349   " This function checks for valid Pascal syntax in the first ten lines.
1350   " Look for either an opening comment or a program start.
1351   " If not found, assume Progress.
1352   let lnum = 1
1353   while lnum <= 10 && lnum < line('$')
1354     let line = getline(lnum)
1355     if line =~ '^\s*\(program\|unit\|procedure\|function\|const\|type\|var\)\>'
1356         \ || line =~ '^\s*{' || line =~ '^\s*(\*'
1357       setf pascal
1358       return
1359     elseif line !~ '^\s*$' || line =~ '^/\*'
1360       " Not an empty line: Doesn't look like valid Pascal code.
1361       " Or it looks like a Progress /* comment
1362       break
1363     endif
1364     let lnum = lnum + 1
1365   endw
1366   setf progress
1367 endfunc
1370 " Software Distributor Product Specification File (POSIX 1387.2-1995)
1371 au BufNewFile,BufRead *.psf                     setf psf
1372 au BufNewFile,BufRead INDEX,INFO
1373         \ if getline(1) =~ '^\s*\(distribution\|installed_software\|root\|bundle\|product\)\s*$' |
1374         \   setf psf |
1375         \ endif
1377 " Prolog
1378 au BufNewFile,BufRead *.pdb                     setf prolog
1380 " Protocols
1381 au BufNewFile,BufRead /etc/protocols            setf protocols
1383 " Pyrex
1384 au BufNewFile,BufRead *.pyx,*.pxd               setf pyrex
1386 " Python
1387 au BufNewFile,BufRead *.py,*.pyw                setf python
1389 " Radiance
1390 au BufNewFile,BufRead *.rad,*.mat               setf radiance
1392 " Ratpoison config/command files
1393 au BufNewFile,BufRead .ratpoisonrc,ratpoisonrc  setf ratpoison
1395 " RCS file
1396 au BufNewFile,BufRead *\,v                      setf rcs
1398 " Readline
1399 au BufNewFile,BufRead .inputrc,inputrc          setf readline
1401 " Registry for MS-Windows
1402 au BufNewFile,BufRead *.reg
1403         \ if getline(1) =~? '^REGEDIT[0-9]*\s*$\|^Windows Registry Editor Version \d*\.\d*\s*$' | setf registry | endif
1405 " Renderman Interface Bytestream
1406 au BufNewFile,BufRead *.rib                     setf rib
1408 " Rexx
1409 au BufNewFile,BufRead *.rexx,*.rex              setf rexx
1411 " R (Splus)
1412 if has("fname_case")
1413   au BufNewFile,BufRead *.s,*.S                 setf r
1414 else
1415   au BufNewFile,BufRead *.s                     setf r
1416 endif
1418 " R Help file
1419 if has("fname_case")
1420   au BufNewFile,BufRead *.rd,*.Rd               setf rhelp
1421 else
1422   au BufNewFile,BufRead *.rd                    setf rhelp
1423 endif
1425 " R noweb file
1426 if has("fname_case")
1427   au BufNewFile,BufRead *.Rnw,*.rnw,*.Snw,*.snw         setf rnoweb
1428 else
1429   au BufNewFile,BufRead *.rnw,*.snw                     setf rnoweb
1430 endif
1432 " Rexx, Rebol or R
1433 au BufNewFile,BufRead *.r,*.R                   call s:FTr()
1435 func! s:FTr()
1436   let max = line("$") > 50 ? 50 : line("$")
1438   for n in range(1, max)
1439     " Rebol is easy to recognize, check for that first
1440     if getline(n) =~ '\<REBOL\>'
1441       setf rebol
1442       return
1443     endif
1444   endfor
1446   for n in range(1, max)
1447     " R has # comments
1448     if getline(n) =~ '^\s*#'
1449       setf r
1450       return
1451     endif
1452     " Rexx has /* comments */
1453     if getline(n) =~ '^\s*/\*'
1454       setf rexx
1455       return
1456     endif
1457   endfor
1459   " Nothing recognized, assume Rexx
1460   setf rexx
1461 endfunc
1463 " Remind
1464 au BufNewFile,BufRead .reminders*               call s:StarSetf('remind')
1466 " Resolv.conf
1467 au BufNewFile,BufRead resolv.conf               setf resolv
1469 " Relax NG Compact
1470 au BufNewFile,BufRead *.rnc                     setf rnc
1472 " RPL/2
1473 au BufNewFile,BufRead *.rpl                     setf rpl
1475 " Robots.txt
1476 au BufNewFile,BufRead robots.txt                setf robots
1478 " Rpcgen
1479 au BufNewFile,BufRead *.x                       setf rpcgen
1481 " reStructuredText Documentation Format
1482 au BufNewFile,BufRead *.rst                     setf rst
1484 " RTF
1485 au BufNewFile,BufRead *.rtf                     setf rtf
1487 " Ruby
1488 au BufNewFile,BufRead *.rb,*.rbw,*.gem,*.gemspec        setf ruby
1490 " Ruby on Rails
1491 au BufNewFile,BufRead *.builder,*.rxml,*.rjs    setf ruby
1493 " Rantfile and Rakefile is like Ruby
1494 au BufNewFile,BufRead [rR]antfile,*.rant,[rR]akefile,*.rake     setf ruby
1496 " S-lang (or shader language!)
1497 au BufNewFile,BufRead *.sl                      setf slang
1499 " Samba config
1500 au BufNewFile,BufRead smb.conf                  setf samba
1502 " SAS script
1503 au BufNewFile,BufRead *.sas                     setf sas
1505 " Sather
1506 au BufNewFile,BufRead *.sa                      setf sather
1508 " Scilab
1509 au BufNewFile,BufRead *.sci,*.sce               setf scilab
1511 " SD: Streaming Descriptors
1512 au BufNewFile,BufRead *.sd                      setf sd
1514 " SDL
1515 au BufNewFile,BufRead *.sdl,*.pr                setf sdl
1517 " sed
1518 au BufNewFile,BufRead *.sed                     setf sed
1520 " Sieve (RFC 3028)
1521 au BufNewFile,BufRead *.siv                     setf sieve
1523 " Sendmail
1524 au BufNewFile,BufRead sendmail.cf               setf sm
1526 " Sendmail .mc files are actually m4
1527 au BufNewFile,BufRead *.mc                      setf m4
1529 " Services
1530 au BufNewFile,BufRead /etc/services             setf services
1532 " Service Location config
1533 au BufNewFile,BufRead /etc/slp.conf             setf slpconf
1535 " Service Location registration
1536 au BufNewFile,BufRead /etc/slp.reg              setf slpreg
1538 " Service Location SPI
1539 au BufNewFile,BufRead /etc/slp.spi              setf slpspi
1541 " Setserial config
1542 au BufNewFile,BufRead /etc/serial.conf          setf setserial
1544 " SGML
1545 au BufNewFile,BufRead *.sgm,*.sgml
1546         \ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'linuxdoc' |
1547         \   setf sgmllnx |
1548         \ elseif getline(1) =~ '<!DOCTYPE.*DocBook' || getline(2) =~ '<!DOCTYPE.*DocBook' |
1549         \   let b:docbk_type="sgml" |
1550         \   setf docbk |
1551         \ else |
1552         \   setf sgml |
1553         \ endif
1555 " SGMLDECL
1556 au BufNewFile,BufRead *.decl,*.dcl,*.dec
1557         \ if getline(1).getline(2).getline(3) =~? '^<!SGML' |
1558         \    setf sgmldecl |
1559         \ endif
1561 " SGML catalog file
1562 au BufNewFile,BufRead catalog                   setf catalog
1563 au BufNewFile,BufRead sgml.catalog*             call s:StarSetf('catalog')
1565 " Shell scripts (sh, ksh, bash, bash2, csh); Allow .profile_foo etc.
1566 " Gentoo ebuilds are actually bash scripts
1567 au BufNewFile,BufRead .bashrc*,bashrc,bash.bashrc,.bash_profile*,.bash_logout*,*.bash,*.ebuild call SetFileTypeSH("bash")
1568 au BufNewFile,BufRead .kshrc*,*.ksh call SetFileTypeSH("ksh")
1569 au BufNewFile,BufRead /etc/profile,.profile*,*.sh,*.env call SetFileTypeSH(getline(1))
1571 " Also called from scripts.vim.
1572 func! SetFileTypeSH(name)
1573   if expand("<amatch>") =~ g:ft_ignore_pat
1574     return
1575   endif
1576   if a:name =~ '\<ksh\>'
1577     let b:is_kornshell = 1
1578     if exists("b:is_bash")
1579       unlet b:is_bash
1580     endif
1581     if exists("b:is_sh")
1582       unlet b:is_sh
1583     endif
1584   elseif exists("g:bash_is_sh") || a:name =~ '\<bash\>' || a:name =~ '\<bash2\>'
1585     let b:is_bash = 1
1586     if exists("b:is_kornshell")
1587       unlet b:is_kornshell
1588     endif
1589     if exists("b:is_sh")
1590       unlet b:is_sh
1591     endif
1592   elseif a:name =~ '\<sh\>'
1593     let b:is_sh = 1
1594     if exists("b:is_kornshell")
1595       unlet b:is_kornshell
1596     endif
1597     if exists("b:is_bash")
1598       unlet b:is_bash
1599     endif
1600   endif
1601   call SetFileTypeShell("sh")
1602 endfunc
1604 " For shell-like file types, check for an "exec" command hidden in a comment,
1605 " as used for Tcl.
1606 " Also called from scripts.vim, thus can't be local to this script.
1607 func! SetFileTypeShell(name)
1608   if expand("<amatch>") =~ g:ft_ignore_pat
1609     return
1610   endif
1611   let l = 2
1612   while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)'
1613     " Skip empty and comment lines.
1614     let l = l + 1
1615   endwhile
1616   if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$'
1617     " Found an "exec" line after a comment with continuation
1618     let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '')
1619     if n =~ '\<tclsh\|\<wish'
1620       setf tcl
1621       return
1622     endif
1623   endif
1624   exe "setf " . a:name
1625 endfunc
1627 " tcsh scripts
1628 au BufNewFile,BufRead .tcshrc*,*.tcsh,tcsh.tcshrc,tcsh.login    call SetFileTypeShell("tcsh")
1630 " csh scripts, but might also be tcsh scripts (on some systems csh is tcsh)
1631 au BufNewFile,BufRead .login*,.cshrc*,csh.cshrc,csh.login,csh.logout,*.csh,.alias  call s:CSH()
1633 func! s:CSH()
1634   if exists("g:filetype_csh")
1635     call SetFileTypeShell(g:filetype_csh)
1636   elseif &shell =~ "tcsh"
1637     call SetFileTypeShell("tcsh")
1638   else
1639     call SetFileTypeShell("csh")
1640   endif
1641 endfunc
1643 " Z-Shell script
1644 au BufNewFile,BufRead .zprofile,/etc/zprofile,.zfbfmarks  setf zsh
1645 au BufNewFile,BufRead .zsh*,.zlog*,.zcompdump*  call s:StarSetf('zsh')
1647 " Scheme
1648 au BufNewFile,BufRead *.scm,*.ss                setf scheme
1650 " Screen RC
1651 au BufNewFile,BufRead .screenrc,screenrc        setf screen
1653 " Simula
1654 au BufNewFile,BufRead *.sim                     setf simula
1656 " SINDA
1657 au BufNewFile,BufRead *.sin,*.s85               setf sinda
1659 " SiSU
1660 au BufNewFile,BufRead *.sst,*.ssm,*.ssi,*.-sst,*._sst setf sisu
1661 au BufNewFile,BufRead *.sst.meta,*.-sst.meta,*._sst.meta setf sisu
1663 " SKILL
1664 au BufNewFile,BufRead *.il,*.ils,*.cdf          setf skill
1666 " SLRN
1667 au BufNewFile,BufRead .slrnrc                   setf slrnrc
1668 au BufNewFile,BufRead *.score                   setf slrnsc
1670 " Smalltalk (and TeX)
1671 au BufNewFile,BufRead *.st                      setf st
1672 au BufNewFile,BufRead *.cls
1673         \ if getline(1) =~ '^%' |
1674         \  setf tex |
1675         \ else |
1676         \  setf st |
1677         \ endif
1679 " Smarty templates
1680 au BufNewFile,BufRead *.tpl                     setf smarty
1682 " SMIL or XML
1683 au BufNewFile,BufRead *.smil
1684         \ if getline(1) =~ '<?\s*xml.*?>' |
1685         \   setf xml |
1686         \ else |
1687         \   setf smil |
1688         \ endif
1690 " SMIL or SNMP MIB file
1691 au BufNewFile,BufRead *.smi
1692         \ if getline(1) =~ '\<smil\>' |
1693         \   setf smil |
1694         \ else |
1695         \   setf mib |
1696         \ endif
1698 " SMITH
1699 au BufNewFile,BufRead *.smt,*.smith             setf smith
1701 " Snobol4 and spitbol
1702 au BufNewFile,BufRead *.sno,*.spt               setf snobol4
1704 " SNMP MIB files
1705 au BufNewFile,BufRead *.mib,*.my                setf mib
1707 " Snort Configuration
1708 au BufNewFile,BufRead *.hog,snort.conf,vision.conf      setf hog
1709 au BufNewFile,BufRead *.rules                   call s:FTRules()
1711 let s:ft_rules_udev_rules_pattern = '^\s*\cudev_rules\s*=\s*"\([^"]\{-1,}\)/*".*'
1712 func! s:FTRules()
1713   try
1714     let config_lines = readfile('/etc/udev/udev.conf')
1715   catch /^Vim\%((\a\+)\)\=:E484/
1716     setf hog
1717     return
1718   endtry
1719   for line in config_lines
1720     if line =~ s:ft_rules_udev_rules_pattern
1721       let udev_rules = substitute(line, s:ft_rules_udev_rules_pattern, '\1', "")
1722       let amatch_dirname = substitute(expand('<amatch>'), '^\(.*\)/[^/]\+$', '\1', "")
1723       if amatch_dirname == udev_rules
1724         setf udevrules
1725       endif
1726       break
1727     endif
1728   endfor
1729   setf hog
1730 endfunc
1733 " Spec (Linux RPM)
1734 au BufNewFile,BufRead *.spec                    setf spec
1736 " Speedup (AspenTech plant simulator)
1737 au BufNewFile,BufRead *.speedup,*.spdata,*.spd  setf spup
1739 " Slice
1740 au BufNewFile,BufRead *.ice                     setf slice
1742 " Spice
1743 au BufNewFile,BufRead *.sp,*.spice              setf spice
1745 " Spyce
1746 au BufNewFile,BufRead *.spy,*.spi               setf spyce
1748 " Squid
1749 au BufNewFile,BufRead squid.conf                setf squid
1751 " SQL for Oracle Designer
1752 au BufNewFile,BufRead *.tyb,*.typ,*.tyc,*.pkb,*.pks     setf sql
1754 " SQL
1755 au BufNewFile,BufRead *.sql                     call s:SQL()
1757 func! s:SQL()
1758   if exists("g:filetype_sql")
1759     exe "setf " . g:filetype_sql
1760   else
1761     setf sql
1762   endif
1763 endfunc
1765 " SQLJ
1766 au BufNewFile,BufRead *.sqlj                    setf sqlj
1768 " SQR
1769 au BufNewFile,BufRead *.sqr,*.sqi               setf sqr
1771 " OpenSSH configuration
1772 au BufNewFile,BufRead ssh_config,*/.ssh/config  setf sshconfig
1774 " OpenSSH server configuration
1775 au BufNewFile,BufRead sshd_config               setf sshdconfig
1777 " Stata
1778 au BufNewFile,BufRead *.ado,*.class,*.do,*.imata,*.mata   setf stata
1780 " SMCL
1781 au BufNewFile,BufRead *.hlp,*.ihlp,*.smcl       setf smcl
1783 " Stored Procedures
1784 au BufNewFile,BufRead *.stp                     setf stp
1786 " Standard ML
1787 au BufNewFile,BufRead *.sml                     setf sml
1789 " Sysctl
1790 au BufNewFile,BufRead /etc/sysctl.conf          setf sysctl
1792 " Sudoers
1793 au BufNewFile,BufRead /etc/sudoers,sudoers.tmp  setf sudoers
1795 " If the file has an extension of 't' and is in a directory 't' then it is
1796 " almost certainly a Perl test file.
1797 " If the first line starts with '#' and contains 'perl' it's probably a Perl
1798 " file.
1799 " (Slow test) If a file contains a 'use' statement then it is almost certainly
1800 " a Perl file.
1801 func! s:FTperl()
1802   if expand("%:e") == 't' && expand("%:p:h:t") == 't'
1803     setf perl
1804     return 1
1805   endif
1806   if getline(1)[0] == '#' && getline(1) =~ 'perl'
1807     setf perl
1808     return 1
1809   endif
1810   if search('^use\s\s*\k', 'nc', 30)
1811     setf perl
1812     return 1
1813   endif
1814   return 0
1815 endfunc
1817 " Tads (or Nroff or Perl test file)
1818 au BufNewFile,BufRead *.t
1819         \ if !s:FTnroff() && !s:FTperl() | setf tads | endif
1821 " Tags
1822 au BufNewFile,BufRead tags                      setf tags
1824 " TAK
1825 au BufNewFile,BufRead *.tak                     setf tak
1827 " Tcl (JACL too)
1828 au BufNewFile,BufRead *.tcl,*.tk,*.itcl,*.itk,*.jacl    setf tcl
1830 " TealInfo
1831 au BufNewFile,BufRead *.tli                     setf tli
1833 " Telix Salt
1834 au BufNewFile,BufRead *.slt                     setf tsalt
1836 " Terminfo
1837 au BufNewFile,BufRead *.ti                      setf terminfo
1839 " TeX
1840 au BufNewFile,BufRead *.latex,*.sty,*.dtx,*.ltx,*.bbl   setf tex
1841 au BufNewFile,BufRead *.tex                     call s:FTtex()
1843 " Choose context, plaintex, or tex (LaTeX) based on these rules:
1844 " 1. Check the first line of the file for "%&<format>".
1845 " 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords.
1846 " 3. Default to "latex" or to g:tex_flavor, can be set in user's vimrc.
1847 func! s:FTtex()
1848   let firstline = getline(1)
1849   if firstline =~ '^%&\s*\a\+'
1850     let format = tolower(matchstr(firstline, '\a\+'))
1851     let format = substitute(format, 'pdf', '', '')
1852     if format == 'tex'
1853       let format = 'plain'
1854     endif
1855   else
1856     " Default value, may be changed later:
1857     let format = exists("g:tex_flavor") ? g:tex_flavor : 'plain'
1858     " Save position, go to the top of the file, find first non-comment line.
1859     let save_cursor = getpos('.')
1860     call cursor(1,1)
1861     let firstNC = search('^\s*[^[:space:]%]', 'c', 1000)
1862     if firstNC " Check the next thousand lines for a LaTeX or ConTeXt keyword.
1863       let lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>'
1864       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\>'
1865       let kwline = search('^\s*\\\%(' . lpat . '\)\|^\s*\\\(' . cpat . '\)',
1866                               \ 'cnp', firstNC + 1000)
1867       if kwline == 1    " lpat matched
1868         let format = 'latex'
1869       elseif kwline == 2        " cpat matched
1870         let format = 'context'
1871       endif             " If neither matched, keep default set above.
1872       " let lline = search('^\s*\\\%(' . lpat . '\)', 'cn', firstNC + 1000)
1873       " let cline = search('^\s*\\\%(' . cpat . '\)', 'cn', firstNC + 1000)
1874       " if cline > 0
1875       "   let format = 'context'
1876       " endif
1877       " if lline > 0 && (cline == 0 || cline > lline)
1878       "   let format = 'tex'
1879       " endif
1880     endif " firstNC
1881     call setpos('.', save_cursor)
1882   endif " firstline =~ '^%&\s*\a\+'
1884   " Translation from formats to file types.  TODO:  add AMSTeX, RevTex, others?
1885   if format == 'plain'
1886     setf plaintex
1887   elseif format == 'context'
1888     setf context
1889   else " probably LaTeX
1890     setf tex
1891   endif
1892   return
1893 endfunc
1895 " Context
1896 au BufNewFile,BufRead tex/context/*/*.tex       setf context
1898 " Texinfo
1899 au BufNewFile,BufRead *.texinfo,*.texi,*.txi    setf texinfo
1901 " TeX configuration
1902 au BufNewFile,BufRead texmf.cnf                 setf texmf
1904 " Tidy config
1905 au BufNewFile,BufRead .tidyrc,tidyrc            setf tidy
1907 " TF mud client
1908 au BufNewFile,BufRead *.tf,.tfrc,tfrc           setf tf
1910 " TPP - Text Presentation Program
1911 au BufNewFile,BufReadPost *.tpp                 setf tpp
1913 " Trustees
1914 au BufNewFile,BufRead trustees.conf             setf trustees
1916 " TSS - Geometry
1917 au BufNewFile,BufReadPost *.tssgm               setf tssgm
1919 " TSS - Optics
1920 au BufNewFile,BufReadPost *.tssop               setf tssop
1922 " TSS - Command Line (temporary)
1923 au BufNewFile,BufReadPost *.tsscl               setf tsscl
1925 " Motif UIT/UIL files
1926 au BufNewFile,BufRead *.uit,*.uil               setf uil
1928 " Udev conf
1929 au BufNewFile,BufRead /etc/udev/udev.conf       setf udevconf
1931 " Udev rules
1932 au BufNewFile,BufRead /etc/udev/rules.d/*.rules setf udevrules
1934 " Udev permissions
1935 au BufNewFile,BufRead /etc/udev/permissions.d/*.permissions setf udevperm
1937 " Udev symlinks config
1938 au BufNewFile,BufRead /etc/udev/cdsymlinks.conf setf sh
1940 " UnrealScript
1941 au BufNewFile,BufRead *.uc                      setf uc
1943 " Updatedb
1944 au BufNewFile,BufRead /etc/updatedb.conf        setf updatedb
1946 " Vera
1947 au BufNewFile,BufRead *.vr,*.vri,*.vrh          setf vera
1949 " Verilog HDL
1950 au BufNewFile,BufRead *.v                       setf verilog
1952 " Verilog-AMS HDL
1953 au BufNewFile,BufRead *.va,*.vams               setf verilogams
1955 " VHDL
1956 au BufNewFile,BufRead *.hdl,*.vhd,*.vhdl,*.vbe,*.vst  setf vhdl
1957 au BufNewFile,BufRead *.vhdl_[0-9]*             call s:StarSetf('vhdl')
1959 " Vim script
1960 au BufNewFile,BufRead *.vim,*.vba,.exrc,_exrc   setf vim
1962 " Viminfo file
1963 au BufNewFile,BufRead .viminfo,_viminfo         setf viminfo
1965 " Virata Config Script File
1966 au BufRead,BufNewFile *.hw,*.module,*.pkg       setf virata
1968 " Visual Basic (also uses *.bas) or FORM
1969 au BufNewFile,BufRead *.frm                     call s:FTVB("form")
1971 " SaxBasic is close to Visual Basic
1972 au BufNewFile,BufRead *.sba                     setf vb
1974 " Vgrindefs file
1975 au BufNewFile,BufRead vgrindefs                 setf vgrindefs
1977 " VRML V1.0c
1978 au BufNewFile,BufRead *.wrl                     setf vrml
1980 " Webmacro
1981 au BufNewFile,BufRead *.wm                      setf webmacro
1983 " Wget config
1984 au BufNewFile,BufRead .wgetrc,wgetrc            setf wget
1986 " Website MetaLanguage
1987 au BufNewFile,BufRead *.wml                     setf wml
1989 " Winbatch
1990 au BufNewFile,BufRead *.wbt                     setf winbatch
1992 " WSML
1993 au BufNewFile,BufRead *.wsml                    setf wsml
1995 " WvDial
1996 au BufNewFile,BufRead wvdial.conf,.wvdialrc     setf wvdial
1998 " CVS RC file
1999 au BufNewFile,BufRead .cvsrc                    setf cvsrc
2001 " CVS commit file
2002 au BufNewFile,BufRead cvs\d\+                   setf cvs
2004 " WEB (*.web is also used for Winbatch: Guess, based on expecting "%" comment
2005 " lines in a WEB file).
2006 au BufNewFile,BufRead *.web
2007         \ if getline(1)[0].getline(2)[0].getline(3)[0].getline(4)[0].getline(5)[0] =~ "%" |
2008         \   setf web |
2009         \ else |
2010         \   setf winbatch |
2011         \ endif
2013 " Windows Scripting Host and Windows Script Component
2014 au BufNewFile,BufRead *.ws[fc]                  setf wsh
2016 " XHTML
2017 au BufNewFile,BufRead *.xhtml,*.xht             setf xhtml
2019 " X Pixmap (dynamically sets colors, use BufEnter to make it work better)
2020 au BufEnter *.xpm
2021         \ if getline(1) =~ "XPM2" |
2022         \   setf xpm2 |
2023         \ else |
2024         \   setf xpm |
2025         \ endif
2026 au BufEnter *.xpm2                              setf xpm2
2028 " XFree86 config
2029 au BufNewFile,BufRead XF86Config
2030         \ if getline(1) =~ '\<XConfigurator\>' |
2031         \   let b:xf86c_xfree86_version = 3 |
2032         \ endif |
2033         \ setf xf86conf
2035 " Xorg config
2036 au BufNewFile,BufRead xorg.conf,xorg.conf-4     let b:xf86c_xfree86_version = 4 | setf xf86conf
2038 " Xinetd conf
2039 au BufNewFile,BufRead /etc/xinetd.conf          setf xinetd
2041 " XS Perl extension interface language
2042 au BufNewFile,BufRead *.xs                      setf xs
2044 " X resources file
2045 au BufNewFile,BufRead .Xdefaults,.Xpdefaults,.Xresources,xdm-config,*.ad setf xdefaults
2047 " Xmath
2048 au BufNewFile,BufRead *.msc,*.msf               setf xmath
2049 au BufNewFile,BufRead *.ms
2050         \ if !s:FTnroff() | setf xmath | endif
2052 " XML
2053 au BufNewFile,BufRead *.xml
2054         \ if getline(1) . getline(2) . getline(3) =~ '<!DOCTYPE.*DocBook' |
2055         \   let b:docbk_type="xml" |
2056         \   setf docbk |
2057         \ else |
2058         \   setf xml |
2059         \ endif
2061 " XMI (holding UML models) is also XML
2062 au BufNewFile,BufRead *.xmi                     setf xml
2064 " CSPROJ files are Visual Studio.NET's XML-based project config files
2065 au BufNewFile,BufRead *.csproj,*.csproj.user    setf xml
2067 " Qt Linguist translation source and Qt User Interface Files are XML
2068 au BufNewFile,BufRead *.ts,*.ui                 setf xml
2070 " TPM's are RDF-based descriptions of TeX packages (Nikolai Weibull)
2071 au BufNewFile,BufRead *.tpm                     setf xml
2073 " Xdg menus
2074 au BufNewFile,BufRead /etc/xdg/menus/*.menu     setf xml
2076 " Xquery
2077 au BufNewFile,BufRead *.xq,*.xql,*.xqm,*.xquery,*.xqy   setf xquery
2079 " XSD
2080 au BufNewFile,BufRead *.xsd                     setf xsd
2082 " Xslt
2083 au BufNewFile,BufRead *.xsl,*.xslt              setf xslt
2085 " Yacc
2086 au BufNewFile,BufRead *.yy                      setf yacc
2088 " Yacc or racc
2089 au BufNewFile,BufRead *.y                       call s:FTy()
2091 func! s:FTy()
2092   let n = 1
2093   while n < 100 && n < line("$")
2094     let line = getline(n)
2095     if line =~ '^\s*%'
2096       setf yacc
2097       return
2098     endif
2099     if getline(n) =~ '^\s*\(#\|class\>\)' && getline(n) !~ '^\s*#\s*include'
2100       setf racc
2101       return
2102     endif
2103     let n = n + 1
2104   endwhile
2105   setf yacc
2106 endfunc
2109 " Yaml
2110 au BufNewFile,BufRead *.yaml,*.yml              setf yaml
2112 " Zope
2113 "   dtml (zope dynamic template markup language), pt (zope page template),
2114 "   cpt (zope form controller page template)
2115 au BufNewFile,BufRead *.dtml,*.pt,*.cpt         call s:FThtml()
2116 "   zsql (zope sql method)
2117 au BufNewFile,BufRead *.zsql                    call s:SQL()
2119 " Z80 assembler asz80
2120 au BufNewFile,BufRead *.z8a                     setf z8a
2122 augroup END
2125 " Source the user-specified filetype file, for backwards compatibility with
2126 " Vim 5.x.
2127 if exists("myfiletypefile") && filereadable(expand(myfiletypefile))
2128   execute "source " . myfiletypefile
2129 endif
2132 " Check for "*" after loading myfiletypefile, so that scripts.vim is only used
2133 " when there are no matching file name extensions.
2134 " Don't do this for compressed files.
2135 augroup filetypedetect
2136 au BufNewFile,BufRead *
2137         \ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
2138         \ | runtime! scripts.vim | endif
2139 au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif
2142 " Extra checks for when no filetype has been detected now.  Mostly used for
2143 " patterns that end in "*".  E.g., "zsh*" matches "zsh.vim", but that's a Vim
2144 " script file.
2145 " Most of these should call s:StarSetf() to avoid names ending in .gz and the
2146 " like are used.
2148 " Asterisk config file
2149 au BufNewFile,BufRead *asterisk/*.conf*         call s:StarSetf('asterisk')
2150 au BufNewFile,BufRead *asterisk*/*voicemail.conf* call s:StarSetf('asteriskvm')
2152 " Bazaar version control
2153 au BufNewFile,BufRead bzr_log.*                 setf bzr
2155 " BIND zone
2156 au BufNewFile,BufRead */named/db.*,*/bind/db.*  call s:StarSetf('bindzone')
2158 " Changelog
2159 au BufNewFile,BufRead [cC]hange[lL]og*
2160         \ if getline(1) =~ '; urgency='
2161         \|  call s:StarSetf('debchangelog')
2162         \|else
2163         \|  call s:StarSetf('changelog')
2164         \|endif
2166 " Crontab
2167 au BufNewFile,BufRead crontab,crontab.*         call s:StarSetf('crontab')
2169 " Debian Sources.list
2170 au BufNewFile,BufRead /etc/apt/sources.list.d/* call s:StarSetf('debsources')
2172 " Dracula
2173 au BufNewFile,BufRead drac.*                    call s:StarSetf('dracula')
2175 " Fvwm
2176 au BufNewFile,BufRead */.fvwm/*                 call s:StarSetf('fvwm')
2177 au BufNewFile,BufRead *fvwmrc*,*fvwm95*.hook
2178         \ let b:fvwm_version = 1 | call s:StarSetf('fvwm')
2179 au BufNewFile,BufRead *fvwm2rc*
2180         \ if expand("<afile>:e") == "m4"
2181         \|  call s:StarSetf('fvwm2m4')
2182         \|else
2183         \|  let b:fvwm_version = 2 | call s:StarSetf('fvwm')
2184         \|endif
2186 " GTK RC
2187 au BufNewFile,BufRead .gtkrc*,gtkrc*            call s:StarSetf('gtkrc')
2189 " Jam
2190 au BufNewFile,BufRead Prl*.*,JAM*.*             call s:StarSetf('jam')
2192 " Jargon
2193 au! BufNewFile,BufRead *jarg*
2194         \ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'THIS IS THE JARGON FILE'
2195         \|  call s:StarSetf('jargon')
2196         \|endif
2198 " Kconfig
2199 au BufNewFile,BufRead Kconfig.*                 call s:StarSetf('kconfig')
2201 " Makefile
2202 au BufNewFile,BufRead [mM]akefile*              call s:StarSetf('make')
2204 " Modconf
2205 au BufNewFile,BufRead /etc/modprobe.*           call s:StarSetf('modconf')
2207 " Ruby Makefile
2208 au BufNewFile,BufRead [rR]akefile*              call s:StarSetf('ruby')
2210 " Mutt setup file
2211 au BufNewFile,BufRead mutt{ng,}rc*,Mutt{ng,}rc*         call s:StarSetf('muttrc')
2213 " Nroff macros
2214 au BufNewFile,BufRead tmac.*                    call s:StarSetf('nroff')
2216 " Pam conf
2217 au BufNewFile,BufRead /etc/pam.d/*              call s:StarSetf('pamconf')
2219 " Printcap and Termcap
2220 au BufNewFile,BufRead *printcap*
2221         \ if !did_filetype()
2222         \|  let b:ptcap_type = "print" | call s:StarSetf('ptcap')
2223         \|endif
2224 au BufNewFile,BufRead *termcap*
2225         \ if !did_filetype()
2226         \|  let b:ptcap_type = "term" | call s:StarSetf('ptcap')
2227         \|endif
2229 " Vim script
2230 au BufNewFile,BufRead *vimrc*                   call s:StarSetf('vim')
2232 " Subversion commit file
2233 au BufNewFile,BufRead svn-commit*.tmp           setf svn
2235 " X resources file
2236 au BufNewFile,BufRead Xresources*,*/app-defaults/*,*/Xresources/* call s:StarSetf('xdefaults')
2238 " XFree86 config
2239 au BufNewFile,BufRead XF86Config-4*
2240         \ let b:xf86c_xfree86_version = 4 | call s:StarSetf('xf86conf')
2241 au BufNewFile,BufRead XF86Config*
2242         \ if getline(1) =~ '\<XConfigurator\>'
2243         \|  let b:xf86c_xfree86_version = 3
2244         \|endif
2245         \|call s:StarSetf('xf86conf')
2247 " X11 xmodmap
2248 au BufNewFile,BufRead *xmodmap*                 call s:StarSetf('xmodmap')
2250 " Xinetd conf
2251 au BufNewFile,BufRead /etc/xinetd.d/*           call s:StarSetf('xinetd')
2253 " Z-Shell script
2254 au BufNewFile,BufRead zsh*,zlog*                call s:StarSetf('zsh')
2257 " Generic configuration file (check this last, it's just guessing!)
2258 au BufNewFile,BufRead,StdinReadPost *
2259         \ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
2260         \    && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#'
2261         \       || getline(4) =~ '^#' || getline(5) =~ '^#') |
2262         \   setf conf |
2263         \ endif
2265 " Use the plugin-filetype checks last, they may overrule any of the previously
2266 " detected filetypes.
2267 runtime! ftdetect/*.vim
2269 augroup END
2272 " If the GUI is already running, may still need to install the Syntax menu.
2273 " Don't do it when the 'M' flag is included in 'guioptions'.
2274 if has("menu") && has("gui_running")
2275       \ && !exists("did_install_syntax_menu") && &guioptions !~# "M"
2276   source <sfile>:p:h/menu.vim
2277 endif
2279 " Function called for testing all functions defined here.  These are
2280 " script-local, thus need to be executed here.
2281 " Returns a string with error messages (hopefully empty).
2282 func! TestFiletypeFuncs(testlist)
2283   let output = ''
2284   for f in a:testlist
2285     try
2286       exe f
2287     catch
2288       let output = output . "\n" . f . ": " . v:exception
2289     endtry
2290   endfor
2291   return output
2292 endfunc
2294 " Restore 'cpoptions'
2295 let &cpo = s:cpo_save
2296 unlet s:cpo_save