1 " Vim support file to detect file types
3 " Maintainer: Bram Moolenaar <Bram@vim.org>
4 " Last Change: 2009 Dec 24
6 " Listen very carefully, I will say this only once
7 if exists("did_load_filetypes")
10 let did_load_filetypes = 1
12 " Line continuation is used here, remove 'C' from 'cpoptions'
16 augroup filetypedetect
19 if exists("*fnameescape")
20 au BufNewFile,BufRead ?\+.orig,?\+.bak,?\+.old,?\+.new,?\+.dpkg-dist,?\+.dpkg-old,?\+.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) |
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")) |
34 echomsg "Warning: some filetypes will not be recognized because this version of Vim does not have fnameescape()"
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\)$'
43 " Function used for patterns that end in a star: don't set the filetype if the
44 " file name matches ft_ignore_pat.
46 if expand("<amatch>") !~ g:ft_ignore_pat
52 au BufNewFile,BufRead *.inp call s:Check_inp()
55 if getline(1) =~ '^\*'
65 if getline(n) =~? "^header surface data"
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
81 au BufNewFile,BufRead *.abap setf abap
84 au BufNewFile,BufRead *.abc setf abc
87 au BufNewFile,BufRead *.abl setf abel
90 au BufNewFile,BufRead *.wrm setf acedb
93 au BufNewFile,BufRead *.adb,*.ads,*.ada setf ada
95 au BufNewFile,BufRead *.gpr,*.ada_m,*.adc setf ada
97 au BufNewFile,BufRead *.gpr setf ada
101 au BufNewFile,BufRead *.tdf setf ahdl
104 au BufNewFile,BufRead *.run setf ampl
107 au BufNewFile,BufRead build.xml setf ant
109 " Apache style config file
110 au BufNewFile,BufRead proftpd.conf* call s:StarSetf('apachestyle')
113 au BufNewFile,BufRead .htaccess,/etc/httpd/*.conf setf apache
114 au BufNewFile,BufRead httpd.conf*,srm.conf*,access.conf*,apache.conf*,apache2.conf*,/etc/apache2/*.conf*,/etc/httpd/conf.d/*.conf* call s:StarSetf('apache')
116 " XA65 MOS6510 cross assembler
117 au BufNewFile,BufRead *.a65 setf a65
120 au BufNewFile,BufRead *.scpt setf applescript
123 au BufNewFile,BufRead *.am
124 \ if expand("<afile>") !~? 'Makefile.am\>' | setf elf | endif
127 au BufNewFile,BufRead ~/.asoundrc,/usr/share/alsa/alsa.conf,/etc/asound.conf setf alsaconf
130 au BufNewFile,BufRead *.aml setf aml
132 " Arch Inventory file
133 au BufNewFile,BufRead .arch-inventory,=tagging-method setf arch
135 " ART*Enterprise (formerly ART-IM)
136 au BufNewFile,BufRead *.art setf art
139 au BufNewFile,BufRead *.asn,*.asn1 setf asn
141 " Active Server Pages (with Visual Basic Script)
142 au BufNewFile,BufRead *.asa
143 \ if exists("g:filetype_asa") |
144 \ exe "setf " . g:filetype_asa |
149 " Active Server Pages (with Perl or Visual Basic Script)
150 au BufNewFile,BufRead *.asp
151 \ if exists("g:filetype_asp") |
152 \ exe "setf " . g:filetype_asp |
153 \ elseif getline(1) . getline(2) . getline(3) =~? "perlscript" |
159 " Grub (must be before catch *.lst)
160 au BufNewFile,BufRead /boot/grub/menu.lst,/boot/grub/grub.conf,/etc/grub.conf setf grub
162 " Assembly (all kinds)
163 " *.lst is not pure assembly, it has two extra columns (address, byte codes)
164 au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst call s:FTasm()
166 " This function checks for the kind of assembly that is wanted by the user, or
167 " can be detected from the first five lines of the file.
169 " make sure b:asmsyntax exists
170 if !exists("b:asmsyntax")
178 " if b:asmsyntax still isn't set, default to asmsyntax or GNU
180 if exists("g:asmsyntax")
181 let b:asmsyntax = g:asmsyntax
183 let b:asmsyntax = "asm"
187 exe "setf " . fnameescape(b:asmsyntax)
190 func! s:FTasmsyntax()
191 " see if file contains any asmsyntax=foo overrides. If so, change
192 " b:asmsyntax appropriately
193 let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4).
195 let match = matchstr(head, '\sasmsyntax=\zs[a-zA-Z0-9]\+\ze\s')
197 let b:asmsyntax = match
198 elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library'))
199 let b:asmsyntax = "vmasm"
204 au BufNewFile,BufRead *.mar setf vmasm
207 au BufNewFile,BufRead *.atl,*.as setf atlas
210 au BufNewFile,BufRead *.au3 setf autoit
213 au BufNewFile,BufRead *.ahk setf autohotkey
216 au BufNewFile,BufRead [mM]akefile.am,GNUmakefile.am setf automake
218 " Autotest .at files are actually m4
219 au BufNewFile,BufRead *.at setf m4
222 au BufNewFile,BufRead *.ave setf ave
225 au BufNewFile,BufRead *.awk setf awk
228 au BufNewFile,BufRead *.mch,*.ref,*.imp setf b
230 " BASIC or Visual Basic
231 au BufNewFile,BufRead *.bas call s:FTVB("basic")
233 " Check if one of the first five lines contains "VB_Name". In that case it is
234 " probably a Visual Basic file. Otherwise it's assumed to be "alt" filetype.
236 if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)'
243 " Visual Basic Script (close to Visual Basic)
244 au BufNewFile,BufRead *.vbs,*.dsm,*.ctl setf vb
246 " IBasic file (similar to QBasic)
247 au BufNewFile,BufRead *.iba,*.ibi setf ibasic
249 " FreeBasic file (similar to QBasic)
250 au BufNewFile,BufRead *.fb,*.bi setf freebasic
252 " Batch file for MSDOS.
253 au BufNewFile,BufRead *.bat,*.sys setf dosbatch
254 " *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd.
255 au BufNewFile,BufRead *.cmd
256 \ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif
258 " Batch file for 4DOS
259 au BufNewFile,BufRead *.btm call s:FTbtm()
261 if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm
269 au BufNewFile,BufRead *.bc setf bc
272 au BufNewFile,BufRead *.bdf setf bdf
274 " BibTeX bibliography database file
275 au BufNewFile,BufRead *.bib setf bib
277 " BibTeX Bibliography Style
278 au BufNewFile,BufRead *.bst setf bst
281 au BufNewFile,BufRead named.conf,rndc.conf setf named
284 au BufNewFile,BufRead named.root setf bindzone
285 au BufNewFile,BufRead *.db call s:BindzoneCheck('')
287 func! s:BindzoneCheck(default)
288 if getline(1).getline(2).getline(3).getline(4) =~ '^; <<>> DiG [0-9.]\+ <<>>\|BIND.*named\|$ORIGIN\|$TTL\|IN\s\+SOA'
290 elseif a:default != ''
291 exe 'setf ' . a:default
296 au BufNewFile,BufRead *.bl setf blank
299 au BufNewFile,BufRead /etc/blkid.tab,/etc/blkid.tab.old setf xml
302 au BufNewFile,BufRead *.c call s:FTlpc()
305 if exists("g:lpc_syntax_for_c")
308 if getline(lnum) =~# '^\(//\|inherit\|private\|protected\|nosave\|string\|object\|mapping\|mixed\)'
319 au BufNewFile,BufRead calendar setf calendar
320 au BufNewFile,BufRead */.calendar/*,
321 \*/share/calendar/*/calendar.*,*/share/calendar/calendar.*
322 \ call s:StarSetf('calendar')
325 au BufNewFile,BufRead *.cs setf cs
328 au BufNewFile,BufRead *.toc setf cdrtoc
331 au BufNewFile,BufRead etc/cdrdao.conf,etc/defaults/cdrdao,etc/default/cdrdao,~/.cdrdao setf cdrdaoconf
334 au BufNewFile,BufRead cfengine.conf setf cfengine
336 " Comshare Dimension Definition Language
337 au BufNewFile,BufRead *.cdl setf cdl
340 au BufNewFile,BufRead *.recipe setf conaryrecipe
342 " Controllable Regex Mutilator
343 au BufNewFile,BufRead *.crm setf crm
346 au BufNewFile,BufRead *.cyn setf cynpp
349 " .cc and .cpp files can be C++ or Cynlib.
350 au BufNewFile,BufRead *.cc
351 \ if exists("cynlib_syntax_for_cc")|setf cynlib|else|setf cpp|endif
352 au BufNewFile,BufRead *.cpp
353 \ if exists("cynlib_syntax_for_cpp")|setf cynlib|else|setf cpp|endif
356 au BufNewFile,BufRead *.cxx,*.c++,*.hh,*.hxx,*.hpp,*.ipp,*.moc,*.tcc,*.inl setf cpp
358 au BufNewFile,BufRead *.C,*.H setf cpp
361 " .h files can be C, Ch C++, ObjC or ObjC++.
362 " Set c_syntax_for_h if you want C, ch_syntax_for_h if you want Ch. ObjC is
363 " detected automatically.
364 au BufNewFile,BufRead *.h call s:FTheader()
367 if match(getline(1, min([line("$"), 200])), '^@\(interface\|end\|class\)') > -1
369 elseif exists("g:c_syntax_for_h")
371 elseif exists("g:ch_syntax_for_h")
379 au BufNewFile,BufRead *.chf setf ch
381 " TLH files are C++ headers generated by Visual C++'s #import from typelibs
382 au BufNewFile,BufRead *.tlh setf cpp
384 " Cascading Style Sheets
385 au BufNewFile,BufRead *.css setf css
387 " Century Term Command Scripts (*.cmd too)
388 au BufNewFile,BufRead *.con setf cterm
391 au BufNewFile,BufRead changelog.Debian,changelog.dch,NEWS.Debian,NEWS.dch
394 au BufNewFile,BufRead [cC]hange[lL]og
395 \ if getline(1) =~ '; urgency='
401 au BufNewFile,BufRead NEWS
402 \ if getline(1) =~ '; urgency='
407 au BufNewFile,BufRead *..ch setf chill
409 " Changes for WEB and CWEB or CHILL
410 au BufNewFile,BufRead *.ch call s:FTchange()
412 " This function checks if one of the first ten lines start with a '@'. In
413 " that case it is probably a change file.
414 " If the first line starts with # or ! it's probably a ch file.
415 " If a line has "main", "include", "//" ir "/*" it's probably ch.
416 " Otherwise CHILL is assumed.
420 if getline(lnum)[0] == '@'
424 if lnum == 1 && (getline(1)[0] == '#' || getline(1)[0] == '!')
428 if getline(lnum) =~ "MODULE"
432 if getline(lnum) =~ 'main\s*(\|#\s*include\|//'
442 au BufNewFile,BufRead *.chopro,*.crd,*.cho,*.crdpro,*.chordpro setf chordpro
445 au BufNewFile,BufRead *.dcl,*.icl setf clean
448 au BufNewFile,BufRead *.eni setf cl
451 au BufNewFile,BufRead *.ent call s:FTent()
454 " This function checks for valid cl syntax in the first five lines.
455 " Look for either an opening comment, '#', or a block start, '{".
456 " If not found, assume SGML.
459 let line = getline(lnum)
460 if line =~ '^\s*[#{]'
463 elseif line !~ '^\s*$'
464 " Not a blank line, not a comment, and not a block start,
465 " so doesn't look like valid cl code.
473 " Clipper (or FoxPro; could also be eviews)
474 au BufNewFile,BufRead *.prg
475 \ if exists("g:filetype_prg") |
476 \ exe "setf " . g:filetype_prg |
482 au BufNewFile,BufRead CMakeLists.txt,*.cmake,*.cmake.in setf cmake
485 au BufNewFile,BufRead ~/.cmus/{autosave,rc,command-history,*.theme} setf cmusrc
486 au BufNewFile,BufRead */cmus/{rc,*.theme} setf cmusrc
489 au BufNewFile,BufRead *.cbl,*.cob,*.lib setf cobol
490 " cobol or zope form controller python script? (heuristic)
491 au BufNewFile,BufRead *.cpy
492 \ if getline(1) =~ '^##' |
499 au BufNewFile,BufRead *.atg setf coco
502 au BufNewFile,BufRead *.cfm,*.cfi,*.cfc setf cf
505 au BufNewFile,BufRead configure.in,configure.ac setf config
507 " CUDA Cumpute Unified Device Architecture
508 au BufNewFile,BufRead *.cu setf cuda
510 " WildPackets EtherPeek Decoder
511 au BufNewFile,BufRead *.dcd setf dcd
513 " Enlightenment configuration files
514 au BufNewFile,BufRead *enlightenment/*.cfg setf c
517 au BufNewFile,BufRead *Eterm/*.cfg setf eterm
520 au BufNewFile,BufRead lynx.cfg setf lynx
523 au BufNewFile,BufRead *baseq[2-3]/*.cfg,*id1/*.cfg setf quake
524 au BufNewFile,BufRead *quake[1-3]/*.cfg setf quake
527 au BufNewFile,BufRead *.qc setf c
530 au BufNewFile,BufRead *.cfg setf cfg
532 " Communicating Sequential Processes
533 au BufNewFile,BufRead *.csp,*.fdr setf csp
535 " CUPL logic description and simulation
536 au BufNewFile,BufRead *.pld setf cupl
537 au BufNewFile,BufRead *.si setf cuplsim
540 au BufNewFile,BufRead */debian/control setf debcontrol
541 au BufNewFile,BufRead control
542 \ if getline(1) =~ '^Source:'
546 " Debian Sources.list
547 au BufNewFile,BufRead /etc/apt/sources.list setf debsources
550 au BufNewFile,BufRead denyhosts.conf setf denyhosts
552 " ROCKLinux package description
553 au BufNewFile,BufRead *.desc setf desc
555 " the D language or dtrace
556 au BufNewFile,BufRead *.d call s:DtraceCheck()
558 func! s:DtraceCheck()
559 let lines = getline(1, min([line("$"), 100]))
560 if match(lines, '^#!\S\+dtrace\|#pragma\s\+D\s\+option\|:\S\{-}:\S\{-}:') > -1
568 au BufNewFile,BufRead *.desktop,.directory setf desktop
571 au BufNewFile,BufRead dict.conf,.dictrc setf dictconf
574 au BufNewFile,BufRead dictd.conf setf dictdconf
577 au BufNewFile,BufRead *.diff,*.rej,*.patch setf diff
580 au BufNewFile,BufRead .dir_colors,/etc/DIR_COLORS setf dircolors
582 " Diva (with Skill) or InstallShield
583 au BufNewFile,BufRead *.rul
584 \ if getline(1).getline(2).getline(3).getline(4).getline(5).getline(6) =~? 'InstallShield' |
590 " DCL (Digital Command Language - vms) or DNS zone file
591 au BufNewFile,BufRead *.com call s:BindzoneCheck('dcl')
594 au BufNewFile,BufRead *.dot setf dot
597 au BufNewFile,BufRead *.lid setf dylanlid
599 " Dylan - intr files (melange)
600 au BufNewFile,BufRead *.intr setf dylanintr
603 au BufNewFile,BufRead *.dylan setf dylan
605 " Microsoft Module Definition
606 au BufNewFile,BufRead *.def setf def
609 au BufNewFile,BufRead *.drac,*.drc,*lvs,*lpe setf dracula
612 au BufNewFile,BufRead *.dsl setf dsl
614 " DTD (Document Type Definition for XML)
615 au BufNewFile,BufRead *.dtd setf dtd
617 " EDIF (*.edf,*.edif,*.edn,*.edo)
618 au BufNewFile,BufRead *.ed\(f\|if\|n\|o\) setf edif
620 " Embedix Component Description
621 au BufNewFile,BufRead *.ecd setf ecd
624 au BufNewFile,BufRead *.e,*.E call s:FTe()
626 " Elinks configuration
627 au BufNewFile,BufRead */etc/elinks.conf,*/.elinks/elinks.conf setf elinks
631 while n < 100 && n < line("$")
632 if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$"
641 " ERicsson LANGuage; Yaws is erlang too
642 au BufNewFile,BufRead *.erl,*.hrl,*.yaws setf erlang
644 " Elm Filter Rules file
645 au BufNewFile,BufRead filter-rules setf elmfilt
648 au BufNewFile,BufRead *esmtprc setf esmtprc
651 au BufNewFile,BufRead *.ec,*.EC setf esqlc
654 au BufNewFile,BufRead *.strl setf esterel
657 au BufNewFile,BufRead *.csc setf csc
660 au BufNewFile,BufRead exim.conf setf exim
663 au BufNewFile,BufRead *.exp setf expect
666 au BufNewFile,BufRead exports setf exports
669 au BufNewFile,BufRead *.factor setf factor
672 au BufNewFile,BufRead .fetchmailrc setf fetchmail
674 " FlexWiki - disabled, because it has side effects when a .wiki file
675 " is not actually FlexWiki
676 "au BufNewFile,BufRead *.wiki setf flexwiki
679 au BufNewFile,BufRead *.fex,*.focexec setf focexec
681 " Focus Master file (but not for auto.master)
682 au BufNewFile,BufRead auto.master setf conf
683 au BufNewFile,BufRead *.mas,*.master setf master
686 au BufNewFile,BufRead *.fs,*.ft setf forth
689 au BufNewFile,BufRead *.frt setf reva
693 au BufNewFile,BufRead *.F,*.FOR,*.FPP,*.FTN,*.F77,*.F90,*.F95 setf fortran
695 au BufNewFile,BufRead *.f,*.for,*.fortran,*.fpp,*.ftn,*.f77,*.f90,*.f95 setf fortran
698 au BufNewFile,BufRead *.fsl setf framescript
701 au BufNewFile,BufRead fstab,mtab setf fstab
704 au BufNewFile,BufRead .gdbinit setf gdb
707 au BufNewFile,BufRead *.mo,*.gdmo setf gdmo
710 au BufNewFile,BufRead *.ged,lltxxxxx.txt setf gedcom
713 autocmd BufNewFile,BufRead *.git/COMMIT_EDITMSG setf gitcommit
714 autocmd BufNewFile,BufRead *.git/config,.gitconfig,.gitmodules setf gitconfig
715 autocmd BufNewFile,BufRead git-rebase-todo setf gitrebase
716 autocmd BufNewFile,BufRead .msg.[0-9]*
717 \ if getline(1) =~ '^From.*# This line is ignored.$' |
718 \ setf gitsendemail |
720 autocmd BufNewFile,BufRead *.git/**
721 \ if getline(1) =~ '^\x\{40\}\>\|^ref: ' |
726 au BufNewFile,BufRead gkrellmrc,gkrellmrc_? setf gkrellmrc
728 " GP scripts (2.0 and onward)
729 au BufNewFile,BufRead *.gp,.gprc setf gp
732 au BufNewFile,BufRead */.gnupg/options setf gpg
733 au BufNewFile,BufRead */.gnupg/gpg.conf setf gpg
734 au BufNewFile,BufRead /usr/**/gnupg/options.skel setf gpg
737 au BufNewFile,BufRead *.gpi setf gnuplot
740 au BufNewFile,BufRead *.gs setf grads
743 au BufNewFile,BufRead *.gretl setf gretl
746 au BufNewFile,BufRead *.groovy setf groovy
749 au BufNewFile,BufRead *.gsp setf gsp
752 au BufNewFile,BufRead /etc/group,/etc/group-,/etc/group.edit,/etc/gshadow,/etc/gshadow-,/etc/gshadow.edit,/var/backups/group.bak,/var/backups/gshadow.bak setf group
755 au BufNewFile,BufRead .gtkrc,gtkrc setf gtkrc
758 au BufNewFile,BufRead *.haml setf haml
760 " Hamster Classic | Playground files
761 au BufNewFile,BufRead *.hsc,*.hsm setf hamster
764 au BufNewFile,BufRead *.hs setf haskell
765 au BufNewFile,BufRead *.lhs setf lhaskell
766 au BufNewFile,BufRead *.chs setf chaskell
769 au BufNewFile,BufRead *.ht setf haste
770 au BufNewFile,BufRead *.htpp setf hastepreproc
773 au BufNewFile,BufRead *.vc,*.ev,*.rs,*.sum,*.errsum setf hercules
776 au BufNewFile,BufRead *.hex,*.h32 setf hex
778 " Tilde (must be before HTML)
779 au BufNewFile,BufRead *.t.html setf tilde
781 " HTML (.shtml and .stm for server side)
782 au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm call s:FThtml()
784 " Distinguish between HTML, XHTML and Django
787 while n < 10 && n < line("$")
788 if getline(n) =~ '\<DTD\s\+XHTML\s'
792 if getline(n) =~ '{%\s*\(extends\|block\)\>'
801 " HTML with Ruby - eRuby
802 au BufNewFile,BufRead *.erb,*.rhtml setf eruby
805 au BufNewFile,BufRead *.html.m4 setf htmlm4
807 " HTML Cheetah template
808 au BufNewFile,BufRead *.tmpl setf htmlcheetah
811 au BufNewFile,BufRead /etc/host.conf setf hostconf
814 au BufNewFile,BufRead /etc/hosts.allow,/etc/hosts.deny setf hostsaccess
817 au BufNewFile,BufRead *.hb setf hb
820 au BufNewFile,BufRead *.icn setf icon
822 " IDL (Interface Description Language)
823 au BufNewFile,BufRead *.idl call s:FTidl()
825 " Distinguish between standard IDL and MS-IDL
828 while n < 50 && n < line("$")
829 if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"'
838 " Microsoft IDL (Interface Description Language) Also *.idl
839 " MOF = WMI (Windows Management Instrumentation) Managed Object Format
840 au BufNewFile,BufRead *.odl,*.mof setf msidl
843 au BufNewFile,BufRead */.icewm/menu setf icemenu
845 " Indent profile (must come before IDL *.pro!)
846 au BufNewFile,BufRead .indent.pro setf indent
847 au BufNewFile,BufRead indent.pro call s:ProtoCheck('indent')
849 " IDL (Interactive Data Language)
850 au BufNewFile,BufRead *.pro call s:ProtoCheck('idlang')
852 " Distinguish between "default" and Cproto prototype file. */
853 func! s:ProtoCheck(default)
854 " Cproto files have a comment in the first line and a function prototype in
855 " the second line, it always ends in ";". Indent files may also have
856 " comments, thus we can't match comments to see the difference.
857 if getline(2) =~ ';$'
860 exe 'setf ' . a:default
866 au BufNewFile,BufRead indentrc setf indent
869 au BufNewFile,BufRead *.inf,*.INF setf inform
872 au BufNewFile,BufRead /etc/initng/**/*.i,*.ii setf initng
875 au BufNewFile,BufRead ipf.conf,ipf6.conf,ipf.rules setf ipfilter
877 " Informix 4GL (source - canonical, include file, I4GL+M4 preproc.)
878 au BufNewFile,BufRead *.4gl,*.4gh,*.m4gl setf fgl
880 " .INI file for MSDOS
881 au BufNewFile,BufRead *.ini setf dosini
884 au BufNewFile,BufRead inittab setf inittab
887 au BufNewFile,BufRead *.iss setf iss
890 au BufNewFile,BufRead *.jal,*.JAL setf jal
893 au BufNewFile,BufRead *.jpl,*.jpr setf jam
896 au BufNewFile,BufRead *.java,*.jav setf java
899 au BufNewFile,BufRead *.jj,*.jjt setf javacc
901 " JavaScript, ECMAScript
902 au BufNewFile,BufRead *.js,*.javascript,*.es,*.jsx setf javascript
905 au BufNewFile,BufRead *.jsp setf jsp
907 " Java Properties resource file (note: doesn't catch font.properties.pl)
908 au BufNewFile,BufRead *.properties,*.properties_??,*.properties_??_?? setf jproperties
909 au BufNewFile,BufRead *.properties_??_??_* call s:StarSetf('jproperties')
912 au BufNewFile,BufRead *.clp setf jess
915 au BufNewFile,BufRead *.jgr setf jgraph
918 au BufNewFile,BufRead *.kix setf kix
921 au BufNewFile,BufRead *.k setf kwt
924 au BufNewFile,BufRead *.ks setf kscript
927 au BufNewFile,BufRead Kconfig,Kconfig.debug setf kconfig
930 au BufNewFile,BufRead *.ace,*.ACE setf lace
933 au BufNewFile,BufRead *.latte,*.lte setf latte
936 au BufNewFile,BufRead /etc/limits setf limits
938 " LambdaProlog (*.mod too, see Modsim)
939 au BufNewFile,BufRead *.sig setf lprolog
942 au BufNewFile,BufRead *.ldif setf ldif
945 au BufNewFile,BufRead *.ld setf ld
948 au BufNewFile,BufRead *.lex,*.l setf lex
951 au BufNewFile,BufRead /etc/libao.conf,*/.libao setf libao
954 au BufNewFile,BufRead /etc/sensors.conf setf sensors
957 au BufNewFile,BufRead lftp.conf,.lftprc,*lftp/rc setf lftp
959 " Lifelines (or Lex for C++!)
960 au BufNewFile,BufRead *.ll setf lifelines
963 au BufNewFile,BufRead lilo.conf* call s:StarSetf('lilo')
965 " Lisp (*.el = ELisp, *.cl = Common Lisp, *.jl = librep Lisp)
967 au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,*.L,.emacs,.sawfishrc setf lisp
969 au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,.emacs,.sawfishrc setf lisp
972 " SBCL implementation of Common Lisp
973 au BufNewFile,BufRead sbclrc,.sbclrc setf lisp
976 au BufNewFile,BufRead *.lite,*.lt setf lite
979 au BufNewFile,BufRead */LiteStep/*/*.rc setf litestep
982 au BufNewFile,BufRead /etc/login.access setf loginaccess
985 au BufNewFile,BufRead /etc/login.defs setf logindefs
988 au BufNewFile,BufRead *.lgt setf logtalk
991 au BufNewFile,BufRead *.lot,*.lotos setf lotos
994 au BufNewFile,BufRead *.lou,*.lout setf lout
997 au BufNewFile,BufRead *.lua setf lua
999 " Linden Scripting Language (Second Life)
1000 au BufNewFile,BufRead *.lsl setf lsl
1002 " Lynx style file (or LotusScript!)
1003 au BufNewFile,BufRead *.lss setf lss
1006 au BufNewFile,BufRead *.m4
1007 \ if expand("<afile>") !~? 'html.m4$\|fvwm2rc' | setf m4 | endif
1010 au BufNewFile,BufRead *.mgp setf mgp
1012 " Mail (for Elm, trn, mutt, muttng, rn, slrn)
1013 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
1016 au BufNewFile,BufRead /etc/mail/aliases,/etc/aliases setf mailaliases
1018 " Mailcap configuration file
1019 au BufNewFile,BufRead .mailcap,mailcap setf mailcap
1022 au BufNewFile,BufRead *[mM]akefile,*.mk,*.mak,*.dsp setf make
1025 au BufNewFile,BufRead *.ist,*.mst setf ist
1028 au BufNewFile,BufRead *.man setf man
1031 au BufNewFile,BufRead /etc/man.conf,man.config setf manconf
1034 au BufNewFile,BufRead *.mv,*.mpl,*.mws setf maple
1036 " Map (UMN mapserver config file)
1037 au BufNewFile,BufRead *.map setf map
1040 au BufNewFile,BufRead *.mason,*.mhtml setf mason
1042 " Matlab or Objective C
1043 au BufNewFile,BufRead *.m call s:FTm()
1048 let line = getline(n)
1049 if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\|//\)'
1057 if line =~ '^\s*(\*'
1063 if exists("g:filetype_m")
1064 exe "setf " . g:filetype_m
1070 " Mathematica notebook
1071 au BufNewFile,BufRead *.nb setf mma
1073 " Maya Extension Language
1074 au BufNewFile,BufRead *.mel setf mel
1076 " Mercurial config (looks like generic config file)
1077 au BufNewFile,BufRead *.hgrc,*hgrc setf cfg
1080 au BufNewFile,BufRead /var/log/messages,/var/log/messages.*[0-9] setf messages
1083 au BufNewFile,BufRead *.mf setf mf
1086 au BufNewFile,BufRead *.mp setf mp
1089 au BufNewFile,BufRead *.mgl setf mgl
1091 " MMIX or VMS makefile
1092 au BufNewFile,BufRead *.mms call s:FTmms()
1094 " Symbian meta-makefile definition (MMP)
1095 au BufNewFile,BufRead *.mmp setf mmp
1100 let line = getline(n)
1101 if line =~ '^\s*\(%\|//\)' || line =~ '^\*'
1115 " Modsim III (or LambdaProlog)
1116 au BufNewFile,BufRead *.mod
1117 \ if getline(1) =~ '\<module\>' |
1124 au BufNewFile,BufRead *.m2,*.DEF,*.MOD,*.md,*.mi setf modula2
1126 " Modula 3 (.m3, .i3, .mg, .ig)
1127 au BufNewFile,BufRead *.[mi][3g] setf modula3
1130 au BufNewFile,BufRead *.isc,*.monk,*.ssc,*.tsc setf monk
1133 au BufNewFile,BufRead *.moo setf moo
1136 au BufNewFile,BufRead /etc/modules.conf,/etc/conf.modules setf modconf
1137 au BufNewFile,BufRead /etc/modutils/*
1138 \ if executable(expand("<afile>")) != 1
1139 \| call s:StarSetf('modconf')
1143 au BufNewFile,BufRead mplayer.conf,*/.mplayer/config setf mplayerconf
1146 au BufNewFile,BufRead *.s19,*.s28,*.s37 setf srec
1149 au BufNewFile,BufRead mrxvtrc,.mrxvtrc setf mrxvtrc
1152 au BufNewFile,BufRead *.msql setf msql
1155 au BufNewFile,BufRead *.mysql setf mysql
1158 au BufNewFile,BufRead *.rc setf rc
1161 au BufRead,BufNewFile *.mu setf mupad
1164 au BufNewFile,BufRead *.mush setf mush
1166 " Mutt setup file (also for Muttng)
1167 au BufNewFile,BufRead Mutt{ng,}rc setf muttrc
1170 au BufNewFile,BufRead /etc/nanorc,.nanorc setf nanorc
1172 " Nastran input/DMAP
1173 "au BufNewFile,BufRead *.dat setf nastran
1176 au BufNewFile,BufRead *.NS[ACGLMNPS] setf natural
1179 au BufNewFile,BufRead .netrc setf netrc
1181 " Novell netware batch files
1182 au BufNewFile,BufRead *.ncf setf ncf
1184 " Nroff/Troff (*.ms and *.t are checked below)
1185 au BufNewFile,BufRead *.me
1186 \ if expand("<afile>") != "read.me" && expand("<afile>") != "click.me" |
1189 au BufNewFile,BufRead *.tr,*.nr,*.roff,*.tmac,*.mom setf nroff
1190 au BufNewFile,BufRead *.[1-9] call s:FTnroff()
1192 " This function checks if one of the first five lines start with a dot. In
1193 " that case it is probably an nroff file: 'filetype' is set and 1 is returned.
1195 if getline(1)[0] . getline(2)[0] . getline(3)[0] . getline(4)[0] . getline(5)[0] =~ '\.'
1202 " Nroff or Objective C++
1203 au BufNewFile,BufRead *.mm call s:FTmm()
1208 let line = getline(n)
1209 if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)'
1219 au BufNewFile,BufRead *.nqc setf nqc
1222 au BufNewFile,BufRead *.nsi setf nsis
1225 au BufNewFile,BufRead *.ml,*.mli,*.mll,*.mly setf ocaml
1228 au BufNewFile,BufRead *.occ setf occam
1231 au BufNewFile,BufRead *.xom,*.xin setf omnimark
1234 au BufNewFile,BufRead *.or setf openroad
1237 au BufNewFile,BufRead *.[Oo][Pp][Ll] setf opl
1239 " Oracle config file
1240 au BufNewFile,BufRead *.ora setf ora
1242 " Packet filter conf
1243 au BufNewFile,BufRead pf.conf setf pf
1246 au BufNewFile,BufRead /etc/pam.conf setf pamconf
1249 au BufNewFile,BufRead *.papp,*.pxml,*.pxsl setf papp
1252 au BufNewFile,BufRead /etc/passwd,/etc/passwd-,/etc/passwd.edit,/etc/shadow,/etc/shadow-,/var/backups/passwd.bak,/var/backups/shadow.bak setf passwd
1255 au BufNewFile,BufRead *.pas setf pascal
1257 " Delphi project file
1258 au BufNewFile,BufRead *.dpr setf pascal
1261 au BufNewFile,BufRead *.pdf setf pdf
1264 if has("fname_case")
1265 au BufNewFile,BufRead *.pl,*.PL call s:FTpl()
1267 au BufNewFile,BufRead *.pl call s:FTpl()
1269 au BufNewFile,BufRead *.plx,*.al setf perl
1272 if exists("g:filetype_pl")
1273 exe "setf " . g:filetype_pl
1275 " recognize Prolog by specific text in the first non-empty line
1276 " require a blank after the '%' because Perl uses "%list" and "%translate"
1277 let l = getline(nextnonblank(1))
1278 if l =~ '\<prolog\>' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-'
1287 au BufNewFile,BufRead *.pm
1288 \ if getline(1) =~ "XPM2" |
1290 \ elseif getline(1) =~ "XPM" |
1297 au BufNewFile,BufRead *.pod setf pod
1299 " Php, php3, php4, etc.
1300 " Also Phtml (was used for PHP 2 in the past)
1301 " Also .ctp for Cake template file
1302 au BufNewFile,BufRead *.php,*.php\d,*.phtml,*.ctp setf php
1305 au BufNewFile,BufRead *.pike,*.lpc,*.ulpc,*.pmod setf pike
1308 au BufNewFile,BufRead */etc/pinforc,*/.pinforc setf pinfo
1310 " Palm Resource compiler
1311 au BufNewFile,BufRead *.rcp setf pilrc
1314 au BufNewFile,BufRead .pinerc,pinerc,.pinercex,pinercex setf pine
1316 " PL/M (also: *.inp)
1317 au BufNewFile,BufRead *.plm,*.p36,*.pac setf plm
1320 au BufNewFile,BufRead *.pls,*.plsql setf plsql
1323 au BufNewFile,BufRead *.plp setf plp
1325 " PO and PO template (GNU gettext)
1326 au BufNewFile,BufRead *.po,*.pot setf po
1328 " Postfix main config
1329 au BufNewFile,BufRead main.cf setf pfmain
1331 " PostScript (+ font files, encapsulated PostScript, Adobe Illustrator)
1332 au BufNewFile,BufRead *.ps,*.pfa,*.afm,*.eps,*.epsf,*.epsi,*.ai setf postscr
1334 " PostScript Printer Description
1335 au BufNewFile,BufRead *.ppd setf ppd
1338 au BufNewFile,BufRead *.pov setf pov
1340 " Povray configuration
1341 au BufNewFile,BufRead .povrayrc setf povini
1343 " Povray, PHP or assembly
1344 au BufNewFile,BufRead *.inc call s:FTinc()
1347 if exists("g:filetype_inc")
1348 exe "setf " . g:filetype_inc
1350 let lines = getline(1).getline(2).getline(3)
1351 if lines =~? "perlscript"
1353 elseif lines =~ "<%"
1355 elseif lines =~ "<?"
1358 call s:FTasmsyntax()
1359 if exists("b:asmsyntax")
1360 exe "setf " . fnameescape(b:asmsyntax)
1368 " Printcap and Termcap
1369 au BufNewFile,BufRead *printcap
1370 \ let b:ptcap_type = "print" | setf ptcap
1371 au BufNewFile,BufRead *termcap
1372 \ let b:ptcap_type = "term" | setf ptcap
1375 "au BufNewFile,BufRead *.g setf antrl
1376 au BufNewFile,BufRead *.g setf pccts
1379 au BufNewFile,BufRead *.it,*.ih setf ppwiz
1382 au BufNewFile,BufRead *.pc setf proc
1384 " Privoxy actions file
1385 au BufNewFile,BufRead *.action setf privoxy
1388 au BufNewFile,BufRead .procmail,.procmailrc setf procmail
1391 au BufNewFile,BufRead *.w call s:FTprogress_cweb()
1393 func! s:FTprogress_cweb()
1394 if exists("g:filetype_w")
1395 exe "setf " . g:filetype_w
1398 if getline(1) =~ '&ANALYZE' || getline(3) =~ '&GLOBAL-DEFINE'
1405 " Progress or assembly
1406 au BufNewFile,BufRead *.i call s:FTprogress_asm()
1408 func! s:FTprogress_asm()
1409 if exists("g:filetype_i")
1410 exe "setf " . g:filetype_i
1413 " This function checks for an assembly comment the first ten lines.
1414 " If not found, assume Progress.
1416 while lnum <= 10 && lnum < line('$')
1417 let line = getline(lnum)
1418 if line =~ '^\s*;' || line =~ '^\*'
1421 elseif line !~ '^\s*$' || line =~ '^/\*'
1422 " Not an empty line: Doesn't look like valid assembly code.
1423 " Or it looks like a Progress /* comment
1431 " Progress or Pascal
1432 au BufNewFile,BufRead *.p call s:FTprogress_pascal()
1434 func! s:FTprogress_pascal()
1435 if exists("g:filetype_p")
1436 exe "setf " . g:filetype_p
1439 " This function checks for valid Pascal syntax in the first ten lines.
1440 " Look for either an opening comment or a program start.
1441 " If not found, assume Progress.
1443 while lnum <= 10 && lnum < line('$')
1444 let line = getline(lnum)
1445 if line =~ '^\s*\(program\|unit\|procedure\|function\|const\|type\|var\)\>'
1446 \ || line =~ '^\s*{' || line =~ '^\s*(\*'
1449 elseif line !~ '^\s*$' || line =~ '^/\*'
1450 " Not an empty line: Doesn't look like valid Pascal code.
1451 " Or it looks like a Progress /* comment
1460 " Software Distributor Product Specification File (POSIX 1387.2-1995)
1461 au BufNewFile,BufRead *.psf setf psf
1462 au BufNewFile,BufRead INDEX,INFO
1463 \ if getline(1) =~ '^\s*\(distribution\|installed_software\|root\|bundle\|product\)\s*$' |
1468 au BufNewFile,BufRead *.pdb setf prolog
1471 au BufNewFile,BufRead *.pml setf promela
1474 au BufNewFile,BufRead /etc/protocols setf protocols
1477 au BufNewFile,BufRead *.pyx,*.pxd setf pyrex
1480 au BufNewFile,BufRead *.py,*.pyw setf python
1482 " Quixote (Python-based web framework)
1483 au BufNewFile,BufRead *.ptl setf python
1486 au BufNewFile,BufRead *.rad,*.mat setf radiance
1488 " Ratpoison config/command files
1489 au BufNewFile,BufRead .ratpoisonrc,ratpoisonrc setf ratpoison
1492 au BufNewFile,BufRead *\,v setf rcs
1495 au BufNewFile,BufRead .inputrc,inputrc setf readline
1497 " Registry for MS-Windows
1498 au BufNewFile,BufRead *.reg
1499 \ if getline(1) =~? '^REGEDIT[0-9]*\s*$\|^Windows Registry Editor Version \d*\.\d*\s*$' | setf registry | endif
1501 " Renderman Interface Bytestream
1502 au BufNewFile,BufRead *.rib setf rib
1505 au BufNewFile,BufRead *.rexx,*.rex,*.jrexx,*.rxj,*.orx setf rexx
1508 if has("fname_case")
1509 au BufNewFile,BufRead *.s,*.S setf r
1511 au BufNewFile,BufRead *.s setf r
1515 if has("fname_case")
1516 au BufNewFile,BufRead *.rd,*.Rd setf rhelp
1518 au BufNewFile,BufRead *.rd setf rhelp
1522 if has("fname_case")
1523 au BufNewFile,BufRead *.Rnw,*.rnw,*.Snw,*.snw setf rnoweb
1525 au BufNewFile,BufRead *.rnw,*.snw setf rnoweb
1529 au BufNewFile,BufRead *.r,*.R call s:FTr()
1532 let max = line("$") > 50 ? 50 : line("$")
1534 for n in range(1, max)
1535 " Rebol is easy to recognize, check for that first
1536 if getline(n) =~? '\<REBOL\>'
1542 for n in range(1, max)
1544 if getline(n) =~ '^\s*#'
1548 " Rexx has /* comments */
1549 if getline(n) =~ '^\s*/\*'
1555 " Nothing recognized, assume Rexx
1560 au BufNewFile,BufRead .reminders* call s:StarSetf('remind')
1561 au BufNewFile,BufRead *.remind,*.rem setf remind
1564 au BufNewFile,BufRead resolv.conf setf resolv
1567 au BufNewFile,BufRead *.rnc setf rnc
1570 au BufNewFile,BufRead *.rpl setf rpl
1573 au BufNewFile,BufRead robots.txt setf robots
1576 au BufNewFile,BufRead *.x setf rpcgen
1578 " reStructuredText Documentation Format
1579 au BufNewFile,BufRead *.rst setf rst
1582 au BufNewFile,BufRead *.rtf setf rtf
1584 " Interactive Ruby shell
1585 au BufNewFile,BufRead .irbrc,irbrc setf ruby
1588 au BufNewFile,BufRead *.rb,*.rbw,*.gem,*.gemspec setf ruby
1591 au BufNewFile,BufRead *.builder,*.rxml,*.rjs setf ruby
1593 " Rantfile and Rakefile is like Ruby
1594 au BufNewFile,BufRead [rR]antfile,*.rant,[rR]akefile,*.rake setf ruby
1596 " S-lang (or shader language, or SmallLisp)
1597 au BufNewFile,BufRead *.sl setf slang
1600 au BufNewFile,BufRead smb.conf setf samba
1603 au BufNewFile,BufRead *.sas setf sas
1606 au BufNewFile,BufRead *.sass setf sass
1609 au BufNewFile,BufRead *.sa setf sather
1612 au BufNewFile,BufRead *.sci,*.sce setf scilab
1614 " SD: Streaming Descriptors
1615 au BufNewFile,BufRead *.sd setf sd
1618 au BufNewFile,BufRead *.sdl,*.pr setf sdl
1621 au BufNewFile,BufRead *.sed setf sed
1624 au BufNewFile,BufRead *.siv setf sieve
1627 au BufNewFile,BufRead sendmail.cf setf sm
1629 " Sendmail .mc files are actually m4. Could also be MS Message text file.
1630 au BufNewFile,BufRead *.mc call s:McSetf()
1633 " Rely on the file to start with a comment.
1634 " MS message text files use ';', Sendmail files use '#' or 'dnl'
1635 for lnum in range(1, min([line("$"), 20]))
1636 let line = getline(lnum)
1637 if line =~ '^\s*\(#\|dnl\)'
1638 setf m4 " Sendmail .mc file
1640 elseif line =~ '^\s*;'
1641 setf msmessages " MS Message text file
1645 setf m4 " Default: Sendmail .mc file
1649 au BufNewFile,BufRead /etc/services setf services
1651 " Service Location config
1652 au BufNewFile,BufRead /etc/slp.conf setf slpconf
1654 " Service Location registration
1655 au BufNewFile,BufRead /etc/slp.reg setf slpreg
1657 " Service Location SPI
1658 au BufNewFile,BufRead /etc/slp.spi setf slpspi
1661 au BufNewFile,BufRead /etc/serial.conf setf setserial
1664 au BufNewFile,BufRead *.sgm,*.sgml
1665 \ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'linuxdoc' |
1667 \ elseif getline(1) =~ '<!DOCTYPE.*DocBook' || getline(2) =~ '<!DOCTYPE.*DocBook' |
1668 \ let b:docbk_type="sgml" |
1675 au BufNewFile,BufRead *.decl,*.dcl,*.dec
1676 \ if getline(1).getline(2).getline(3) =~? '^<!SGML' |
1681 au BufNewFile,BufRead catalog setf catalog
1682 au BufNewFile,BufRead sgml.catalog* call s:StarSetf('catalog')
1684 " Shell scripts (sh, ksh, bash, bash2, csh); Allow .profile_foo etc.
1685 " Gentoo ebuilds are actually bash scripts
1686 au BufNewFile,BufRead .bashrc*,bashrc,bash.bashrc,.bash_profile*,.bash_logout*,*.bash,*.ebuild call SetFileTypeSH("bash")
1687 au BufNewFile,BufRead .kshrc*,*.ksh call SetFileTypeSH("ksh")
1688 au BufNewFile,BufRead /etc/profile,.profile*,*.sh,*.env call SetFileTypeSH(getline(1))
1690 " Also called from scripts.vim.
1691 func! SetFileTypeSH(name)
1692 if expand("<amatch>") =~ g:ft_ignore_pat
1695 if a:name =~ '\<csh\>'
1696 " Some .sh scripts contain #!/bin/csh.
1697 call SetFileTypeShell("csh")
1699 elseif a:name =~ '\<tcsh\>'
1700 " Some .sh scripts contain #!/bin/tcsh.
1701 call SetFileTypeShell("tcsh")
1703 elseif a:name =~ '\<ksh\>'
1704 let b:is_kornshell = 1
1705 if exists("b:is_bash")
1708 if exists("b:is_sh")
1711 elseif exists("g:bash_is_sh") || a:name =~ '\<bash\>' || a:name =~ '\<bash2\>'
1713 if exists("b:is_kornshell")
1714 unlet b:is_kornshell
1716 if exists("b:is_sh")
1719 elseif a:name =~ '\<sh\>'
1721 if exists("b:is_kornshell")
1722 unlet b:is_kornshell
1724 if exists("b:is_bash")
1728 call SetFileTypeShell("sh")
1731 " For shell-like file types, check for an "exec" command hidden in a comment,
1733 " Also called from scripts.vim, thus can't be local to this script.
1734 func! SetFileTypeShell(name)
1735 if expand("<amatch>") =~ g:ft_ignore_pat
1739 while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)'
1740 " Skip empty and comment lines.
1743 if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$'
1744 " Found an "exec" line after a comment with continuation
1745 let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '')
1746 if n =~ '\<tclsh\|\<wish'
1751 exe "setf " . a:name
1755 au BufNewFile,BufRead .tcshrc*,*.tcsh,tcsh.tcshrc,tcsh.login call SetFileTypeShell("tcsh")
1757 " csh scripts, but might also be tcsh scripts (on some systems csh is tcsh)
1758 au BufNewFile,BufRead .login*,.cshrc*,csh.cshrc,csh.login,csh.logout,*.csh,.alias call s:CSH()
1761 if exists("g:filetype_csh")
1762 call SetFileTypeShell(g:filetype_csh)
1763 elseif &shell =~ "tcsh"
1764 call SetFileTypeShell("tcsh")
1766 call SetFileTypeShell("csh")
1771 au BufNewFile,BufRead .zprofile,/etc/zprofile,.zfbfmarks setf zsh
1772 au BufNewFile,BufRead .zsh*,.zlog*,.zcompdump* call s:StarSetf('zsh')
1773 au BufNewFile,BufRead *.zsh setf zsh
1776 au BufNewFile,BufRead *.scm,*.ss setf scheme
1779 au BufNewFile,BufRead .screenrc,screenrc setf screen
1782 au BufNewFile,BufRead *.sim setf simula
1785 au BufNewFile,BufRead *.sin,*.s85 setf sinda
1788 au BufNewFile,BufRead *.sst,*.ssm,*.ssi,*.-sst,*._sst setf sisu
1789 au BufNewFile,BufRead *.sst.meta,*.-sst.meta,*._sst.meta setf sisu
1792 au BufNewFile,BufRead *.il,*.ils,*.cdf setf skill
1795 au BufNewFile,BufRead .slrnrc setf slrnrc
1796 au BufNewFile,BufRead *.score setf slrnsc
1798 " Smalltalk (and TeX)
1799 au BufNewFile,BufRead *.st setf st
1800 au BufNewFile,BufRead *.cls
1801 \ if getline(1) =~ '^%' |
1808 au BufNewFile,BufRead *.tpl setf smarty
1811 au BufNewFile,BufRead *.smil
1812 \ if getline(1) =~ '<?\s*xml.*?>' |
1818 " SMIL or SNMP MIB file
1819 au BufNewFile,BufRead *.smi
1820 \ if getline(1) =~ '\<smil\>' |
1827 au BufNewFile,BufRead *.smt,*.smith setf smith
1829 " Snobol4 and spitbol
1830 au BufNewFile,BufRead *.sno,*.spt setf snobol4
1833 au BufNewFile,BufRead *.mib,*.my setf mib
1835 " Snort Configuration
1836 au BufNewFile,BufRead *.hog,snort.conf,vision.conf setf hog
1837 au BufNewFile,BufRead *.rules call s:FTRules()
1839 let s:ft_rules_udev_rules_pattern = '^\s*\cudev_rules\s*=\s*"\([^"]\{-1,}\)/*".*'
1841 let path = expand('<amatch>:p')
1842 if path =~ '^/etc/udev/\%(rules\.d/\)\=.*\.rules$'
1846 if path =~ '^/etc/ufw/'
1847 setf conf " Better than hog
1851 let config_lines = readfile('/etc/udev/udev.conf')
1852 catch /^Vim\%((\a\+)\)\=:E484/
1856 let dir = expand('<amatch>:p:h')
1857 for line in config_lines
1858 if line =~ s:ft_rules_udev_rules_pattern
1859 let udev_rules = substitute(line, s:ft_rules_udev_rules_pattern, '\1', "")
1860 if dir == udev_rules
1871 au BufNewFile,BufRead *.spec setf spec
1873 " Speedup (AspenTech plant simulator)
1874 au BufNewFile,BufRead *.speedup,*.spdata,*.spd setf spup
1877 au BufNewFile,BufRead *.ice setf slice
1880 au BufNewFile,BufRead *.sp,*.spice setf spice
1883 au BufNewFile,BufRead *.spy,*.spi setf spyce
1886 au BufNewFile,BufRead squid.conf setf squid
1888 " SQL for Oracle Designer
1889 au BufNewFile,BufRead *.tyb,*.typ,*.tyc,*.pkb,*.pks setf sql
1892 au BufNewFile,BufRead *.sql call s:SQL()
1895 if exists("g:filetype_sql")
1896 exe "setf " . g:filetype_sql
1903 au BufNewFile,BufRead *.sqlj setf sqlj
1906 au BufNewFile,BufRead *.sqr,*.sqi setf sqr
1908 " OpenSSH configuration
1909 au BufNewFile,BufRead ssh_config,*/.ssh/config setf sshconfig
1911 " OpenSSH server configuration
1912 au BufNewFile,BufRead sshd_config setf sshdconfig
1915 au BufNewFile,BufRead *.ado,*.class,*.do,*.imata,*.mata setf stata
1918 au BufNewFile,BufRead *.hlp,*.ihlp,*.smcl setf smcl
1921 au BufNewFile,BufRead *.stp setf stp
1924 au BufNewFile,BufRead *.sml setf sml
1926 " Sratus VOS command macro
1927 au BufNewFile,BufRead *.cm setf voscm
1930 au BufNewFile,BufRead /etc/sysctl.conf setf sysctl
1932 " Synopsys Design Constraints
1933 au BufNewFile,BufRead *.sdc setf sdc
1936 au BufNewFile,BufRead /etc/sudoers,sudoers.tmp setf sudoers
1938 " If the file has an extension of 't' and is in a directory 't' then it is
1939 " almost certainly a Perl test file.
1940 " If the first line starts with '#' and contains 'perl' it's probably a Perl
1942 " (Slow test) If a file contains a 'use' statement then it is almost certainly
1945 if expand("%:e") == 't' && expand("%:p:h:t") == 't'
1949 if getline(1)[0] == '#' && getline(1) =~ 'perl'
1953 if search('^use\s\s*\k', 'nc', 30)
1960 " Tads (or Nroff or Perl test file)
1961 au BufNewFile,BufRead *.t
1962 \ if !s:FTnroff() && !s:FTperl() | setf tads | endif
1965 au BufNewFile,BufRead tags setf tags
1968 au BufNewFile,BufRead *.tak setf tak
1971 au BufRead,BufNewFile {pending,completed,undo}.data setf taskdata
1972 au BufRead,BufNewFile *.task setf taskedit
1975 au BufNewFile,BufRead *.tcl,*.tk,*.itcl,*.itk,*.jacl setf tcl
1978 au BufNewFile,BufRead *.tli setf tli
1981 au BufNewFile,BufRead *.slt setf tsalt
1984 au BufNewFile,BufRead *.ti setf terminfo
1987 au BufNewFile,BufRead *.latex,*.sty,*.dtx,*.ltx,*.bbl setf tex
1988 au BufNewFile,BufRead *.tex call s:FTtex()
1990 " Choose context, plaintex, or tex (LaTeX) based on these rules:
1991 " 1. Check the first line of the file for "%&<format>".
1992 " 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords.
1993 " 3. Default to "latex" or to g:tex_flavor, can be set in user's vimrc.
1995 let firstline = getline(1)
1996 if firstline =~ '^%&\s*\a\+'
1997 let format = tolower(matchstr(firstline, '\a\+'))
1998 let format = substitute(format, 'pdf', '', '')
2000 let format = 'plain'
2003 " Default value, may be changed later:
2004 let format = exists("g:tex_flavor") ? g:tex_flavor : 'plain'
2005 " Save position, go to the top of the file, find first non-comment line.
2006 let save_cursor = getpos('.')
2008 let firstNC = search('^\s*[^[:space:]%]', 'c', 1000)
2009 if firstNC " Check the next thousand lines for a LaTeX or ConTeXt keyword.
2010 let lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>'
2011 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\>'
2012 let kwline = search('^\s*\\\%(' . lpat . '\)\|^\s*\\\(' . cpat . '\)',
2013 \ 'cnp', firstNC + 1000)
2014 if kwline == 1 " lpat matched
2015 let format = 'latex'
2016 elseif kwline == 2 " cpat matched
2017 let format = 'context'
2018 endif " If neither matched, keep default set above.
2019 " let lline = search('^\s*\\\%(' . lpat . '\)', 'cn', firstNC + 1000)
2020 " let cline = search('^\s*\\\%(' . cpat . '\)', 'cn', firstNC + 1000)
2022 " let format = 'context'
2024 " if lline > 0 && (cline == 0 || cline > lline)
2025 " let format = 'tex'
2028 call setpos('.', save_cursor)
2029 endif " firstline =~ '^%&\s*\a\+'
2031 " Translation from formats to file types. TODO: add AMSTeX, RevTex, others?
2032 if format == 'plain'
2034 elseif format == 'context'
2036 else " probably LaTeX
2043 au BufNewFile,BufRead tex/context/*/*.tex,*.mkii,*.mkiv setf context
2046 au BufNewFile,BufRead *.texinfo,*.texi,*.txi setf texinfo
2049 au BufNewFile,BufRead texmf.cnf setf texmf
2052 au BufNewFile,BufRead .tidyrc,tidyrc setf tidy
2055 au BufNewFile,BufRead *.tf,.tfrc,tfrc setf tf
2057 " TPP - Text Presentation Program
2058 au BufNewFile,BufReadPost *.tpp setf tpp
2061 au BufNewFile,BufRead trustees.conf setf trustees
2064 au BufNewFile,BufReadPost *.tssgm setf tssgm
2067 au BufNewFile,BufReadPost *.tssop setf tssop
2069 " TSS - Command Line (temporary)
2070 au BufNewFile,BufReadPost *.tsscl setf tsscl
2072 " Motif UIT/UIL files
2073 au BufNewFile,BufRead *.uit,*.uil setf uil
2076 au BufNewFile,BufRead /etc/udev/udev.conf setf udevconf
2079 au BufNewFile,BufRead /etc/udev/permissions.d/*.permissions setf udevperm
2081 " Udev symlinks config
2082 au BufNewFile,BufRead /etc/udev/cdsymlinks.conf setf sh
2085 au BufNewFile,BufRead *.uc setf uc
2088 au BufNewFile,BufRead /etc/updatedb.conf setf updatedb
2091 au BufNewFile,BufRead *.vr,*.vri,*.vrh setf vera
2094 au BufNewFile,BufRead *.v setf verilog
2097 au BufNewFile,BufRead *.va,*.vams setf verilogams
2100 au BufNewFile,BufRead *.hdl,*.vhd,*.vhdl,*.vbe,*.vst setf vhdl
2101 au BufNewFile,BufRead *.vhdl_[0-9]* call s:StarSetf('vhdl')
2104 au BufNewFile,BufRead *.vim,*.vba,.exrc,_exrc setf vim
2107 au BufNewFile,BufRead .viminfo,_viminfo setf viminfo
2109 " Virata Config Script File or Drupal module
2110 au BufRead,BufNewFile *.hw,*.module,*.pkg
2111 \ if getline(1) =~ '<?php' |
2117 " Visual Basic (also uses *.bas) or FORM
2118 au BufNewFile,BufRead *.frm call s:FTVB("form")
2120 " SaxBasic is close to Visual Basic
2121 au BufNewFile,BufRead *.sba setf vb
2124 au BufNewFile,BufRead vgrindefs setf vgrindefs
2127 au BufNewFile,BufRead *.wrl setf vrml
2130 au BufNewFile,BufRead *.wm setf webmacro
2133 au BufNewFile,BufRead .wgetrc,wgetrc setf wget
2135 " Website MetaLanguage
2136 au BufNewFile,BufRead *.wml setf wml
2139 au BufNewFile,BufRead *.wbt setf winbatch
2142 au BufNewFile,BufRead *.wsml setf wsml
2145 au BufNewFile,BufRead wvdial.conf,.wvdialrc setf wvdial
2148 au BufNewFile,BufRead .cvsrc setf cvsrc
2151 au BufNewFile,BufRead cvs\d\+ setf cvs
2153 " WEB (*.web is also used for Winbatch: Guess, based on expecting "%" comment
2154 " lines in a WEB file).
2155 au BufNewFile,BufRead *.web
2156 \ if getline(1)[0].getline(2)[0].getline(3)[0].getline(4)[0].getline(5)[0] =~ "%" |
2162 " Windows Scripting Host and Windows Script Component
2163 au BufNewFile,BufRead *.ws[fc] setf wsh
2166 au BufNewFile,BufRead *.xhtml,*.xht setf xhtml
2168 " X Pixmap (dynamically sets colors, use BufEnter to make it work better)
2170 \ if getline(1) =~ "XPM2" |
2175 au BufEnter *.xpm2 setf xpm2
2178 au BufNewFile,BufRead XF86Config
2179 \ if getline(1) =~ '\<XConfigurator\>' |
2180 \ let b:xf86c_xfree86_version = 3 |
2185 au BufNewFile,BufRead xorg.conf,xorg.conf-4 let b:xf86c_xfree86_version = 4 | setf xf86conf
2188 au BufNewFile,BufRead /etc/xinetd.conf setf xinetd
2190 " XS Perl extension interface language
2191 au BufNewFile,BufRead *.xs setf xs
2194 au BufNewFile,BufRead .Xdefaults,.Xpdefaults,.Xresources,xdm-config,*.ad setf xdefaults
2197 au BufNewFile,BufRead *.msc,*.msf setf xmath
2198 au BufNewFile,BufRead *.ms
2199 \ if !s:FTnroff() | setf xmath | endif
2201 " XML specific variants: docbk and xbl
2202 au BufNewFile,BufRead *.xml call s:FTxml()
2206 while n < 100 && n < line("$")
2207 let line = getline(n)
2208 if line =~ '<!DOCTYPE.*DocBook'
2209 let b:docbk_type = "xml"
2213 if line =~ 'xmlns:xbl="http://www.mozilla.org/xbl"'
2222 " XMI (holding UML models) is also XML
2223 au BufNewFile,BufRead *.xmi setf xml
2225 " CSPROJ files are Visual Studio.NET's XML-based project config files
2226 au BufNewFile,BufRead *.csproj,*.csproj.user setf xml
2228 " Qt Linguist translation source and Qt User Interface Files are XML
2229 au BufNewFile,BufRead *.ts,*.ui setf xml
2231 " TPM's are RDF-based descriptions of TeX packages (Nikolai Weibull)
2232 au BufNewFile,BufRead *.tpm setf xml
2235 au BufNewFile,BufRead /etc/xdg/menus/*.menu setf xml
2237 " ATI graphics driver configuration
2238 au BufNewFile,BufRead fglrxrc setf xml
2240 " XLIFF (XML Localisation Interchange File Format) is also XML
2241 au BufNewFile,BufRead *.xlf setf xml
2242 au BufNewFile,BufRead *.xliff setf xml
2244 " X11 xmodmap (also see below)
2245 au BufNewFile,BufRead *Xmodmap setf xmodmap
2248 au BufNewFile,BufRead *.xq,*.xql,*.xqm,*.xquery,*.xqy setf xquery
2251 au BufNewFile,BufRead *.xsd setf xsd
2254 au BufNewFile,BufRead *.xsl,*.xslt setf xslt
2257 au BufNewFile,BufRead *.yy setf yacc
2260 au BufNewFile,BufRead *.y call s:FTy()
2264 while n < 100 && n < line("$")
2265 let line = getline(n)
2270 if getline(n) =~ '^\s*\(#\|class\>\)' && getline(n) !~ '^\s*#\s*include'
2281 au BufNewFile,BufRead *.yaml,*.yml setf yaml
2284 " dtml (zope dynamic template markup language), pt (zope page template),
2285 " cpt (zope form controller page template)
2286 au BufNewFile,BufRead *.dtml,*.pt,*.cpt call s:FThtml()
2287 " zsql (zope sql method)
2288 au BufNewFile,BufRead *.zsql call s:SQL()
2290 " Z80 assembler asz80
2291 au BufNewFile,BufRead *.z8a setf z8a
2296 " Source the user-specified filetype file, for backwards compatibility with
2298 if exists("myfiletypefile") && filereadable(expand(myfiletypefile))
2299 execute "source " . myfiletypefile
2303 " Check for "*" after loading myfiletypefile, so that scripts.vim is only used
2304 " when there are no matching file name extensions.
2305 " Don't do this for compressed files.
2306 augroup filetypedetect
2307 au BufNewFile,BufRead *
2308 \ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
2309 \ | runtime! scripts.vim | endif
2310 au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif
2313 " Extra checks for when no filetype has been detected now. Mostly used for
2314 " patterns that end in "*". E.g., "zsh*" matches "zsh.vim", but that's a Vim
2316 " Most of these should call s:StarSetf() to avoid names ending in .gz and the
2319 " More Apache files.
2320 au BufNewFile,BufRead /etc/apache2/conf.*/*,/etc/apache2/sites-*/*,/etc/apache2/mods-*/* call s:StarSetf('apache')
2322 " Asterisk config file
2323 au BufNewFile,BufRead *asterisk/*.conf* call s:StarSetf('asterisk')
2324 au BufNewFile,BufRead *asterisk*/*voicemail.conf* call s:StarSetf('asteriskvm')
2326 " Bazaar version control
2327 au BufNewFile,BufRead bzr_log.* setf bzr
2330 au BufNewFile,BufRead */named/db.*,*/bind/db.* call s:StarSetf('bindzone')
2333 au BufNewFile,BufRead [cC]hange[lL]og*
2334 \ if getline(1) =~ '; urgency='
2335 \| call s:StarSetf('debchangelog')
2337 \| call s:StarSetf('changelog')
2341 au BufNewFile,BufRead crontab,crontab.*,/etc/cron.d/* call s:StarSetf('crontab')
2343 " Debian Sources.list
2344 au BufNewFile,BufRead /etc/apt/sources.list.d/* call s:StarSetf('debsources')
2347 au BufNewFile,BufRead drac.* call s:StarSetf('dracula')
2350 au BufNewFile,BufRead */.fvwm/* call s:StarSetf('fvwm')
2351 au BufNewFile,BufRead *fvwmrc*,*fvwm95*.hook
2352 \ let b:fvwm_version = 1 | call s:StarSetf('fvwm')
2353 au BufNewFile,BufRead *fvwm2rc*
2354 \ if expand("<afile>:e") == "m4"
2355 \| call s:StarSetf('fvwm2m4')
2357 \| let b:fvwm_version = 2 | call s:StarSetf('fvwm')
2361 au BufNewFile,BufRead /tmp/lltmp* call s:StarSetf('gedcom')
2364 au BufNewFile,BufRead .gtkrc*,gtkrc* call s:StarSetf('gtkrc')
2367 au BufNewFile,BufRead Prl*.*,JAM*.* call s:StarSetf('jam')
2370 au! BufNewFile,BufRead *jarg*
2371 \ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'THIS IS THE JARGON FILE'
2372 \| call s:StarSetf('jargon')
2376 au BufNewFile,BufRead Kconfig.* call s:StarSetf('kconfig')
2379 au BufNewFile,BufRead [mM]akefile* call s:StarSetf('make')
2382 au BufNewFile,BufRead [rR]akefile* call s:StarSetf('ruby')
2384 " Mail (also matches muttrc.vim, so this is below the other checks)
2385 au BufNewFile,BufRead mutt[[:alnum:]._-]\{6\} setf mail
2388 au BufNewFile,BufRead /etc/modprobe.* call s:StarSetf('modconf')
2391 au BufNewFile,BufRead .mutt{ng,}rc*,*/.mutt{ng,}/mutt{ng,}rc* call s:StarSetf('muttrc')
2392 au BufNewFile,BufRead mutt{ng,}rc*,Mutt{ng,}rc* call s:StarSetf('muttrc')
2395 au BufNewFile,BufRead tmac.* call s:StarSetf('nroff')
2398 au BufNewFile,BufRead /etc/pam.d/* call s:StarSetf('pamconf')
2400 " Printcap and Termcap
2401 au BufNewFile,BufRead *printcap*
2402 \ if !did_filetype()
2403 \| let b:ptcap_type = "print" | call s:StarSetf('ptcap')
2405 au BufNewFile,BufRead *termcap*
2406 \ if !did_filetype()
2407 \| let b:ptcap_type = "term" | call s:StarSetf('ptcap')
2411 au BufNewFile,BufRead *vimrc* call s:StarSetf('vim')
2413 " Subversion commit file
2414 au BufNewFile,BufRead svn-commit*.tmp setf svn
2417 au BufNewFile,BufRead Xresources*,*/app-defaults/*,*/Xresources/* call s:StarSetf('xdefaults')
2420 au BufNewFile,BufRead XF86Config-4*
2421 \ let b:xf86c_xfree86_version = 4 | call s:StarSetf('xf86conf')
2422 au BufNewFile,BufRead XF86Config*
2423 \ if getline(1) =~ '\<XConfigurator\>'
2424 \| let b:xf86c_xfree86_version = 3
2426 \|call s:StarSetf('xf86conf')
2429 au BufNewFile,BufRead *xmodmap* call s:StarSetf('xmodmap')
2432 au BufNewFile,BufRead /etc/xinetd.d/* call s:StarSetf('xinetd')
2435 au BufNewFile,BufRead zsh*,zlog* call s:StarSetf('zsh')
2439 " Use the filetype detect plugins. They may overrule any of the previously
2440 " detected filetypes.
2441 runtime! ftdetect/*.vim
2444 " Generic configuration file (check this last, it's just guessing!)
2445 au BufNewFile,BufRead,StdinReadPost *
2446 \ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
2447 \ && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#'
2448 \ || getline(4) =~ '^#' || getline(5) =~ '^#') |
2455 " If the GUI is already running, may still need to install the Syntax menu.
2456 " Don't do it when the 'M' flag is included in 'guioptions'.
2457 if has("menu") && has("gui_running")
2458 \ && !exists("did_install_syntax_menu") && &guioptions !~# "M"
2459 source <sfile>:p:h/menu.vim
2462 " Function called for testing all functions defined here. These are
2463 " script-local, thus need to be executed here.
2464 " Returns a string with error messages (hopefully empty).
2465 func! TestFiletypeFuncs(testlist)
2471 let output = output . "\n" . f . ": " . v:exception
2477 " Restore 'cpoptions'
2478 let &cpo = s:cpo_save