1 " Vim support file to detect file types
3 " Maintainer: Bram Moolenaar <Bram@vim.org>
4 " Last Change: 2008 Apr 01
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 au BufNewFile,BufRead ?\+.orig,?\+.bak,?\+.old,?\+.new,?\+.rpmsave,?\+.rpmnew
20 \ exe "doau filetypedetect BufRead " . expand("<afile>:r")
21 au BufNewFile,BufRead *~
22 \ let s:name = expand("<afile>") |
23 \ let s:short = substitute(s:name, '\~$', '', '') |
24 \ if s:name != s:short && s:short != "" |
25 \ exe "doau filetypedetect BufRead " . s:short |
29 au BufNewFile,BufRead ?\+.in
30 \ if expand("<afile>:t") != "configure.in" |
31 \ exe "doau filetypedetect BufRead " . expand("<afile>:r") |
34 " Pattern used to match file names which should not be inspected.
35 " Currently finds compressed files.
36 if !exists("g:ft_ignore_pat")
37 let g:ft_ignore_pat = '\.\(Z\|gz\|bz2\|zip\|tgz\)$'
40 " Function used for patterns that end in a star: don't set the filetype if the
41 " file name matches ft_ignore_pat.
43 if expand("<amatch>") !~ g:ft_ignore_pat
49 au BufNewFile,BufRead *.inp call s:Check_inp()
52 if getline(1) =~ '^\*'
62 if getline(n) =~? "^header surface data"
72 au BufNewFile,BufRead *.aap setf aap
74 " A2ps printing utility
75 au BufNewFile,BufRead etc/a2ps.cfg,etc/a2ps/*.cfg,a2psrc,.a2psrc setf a2ps
78 au BufNewFile,BufRead *.abap setf abap
81 au BufNewFile,BufRead *.abc setf abc
84 au BufNewFile,BufRead *.abl setf abel
87 au BufNewFile,BufRead *.wrm setf acedb
90 au BufNewFile,BufRead *.adb,*.ads,*.ada setf ada
92 au BufNewFile,BufRead *.gpr,*.ada_m,*.adc setf ada
94 au BufNewFile,BufRead *.gpr setf ada
98 au BufNewFile,BufRead *.tdf setf ahdl
101 au BufNewFile,BufRead *.run setf ampl
104 au BufNewFile,BufRead build.xml setf ant
106 " Apache style config file
107 au BufNewFile,BufRead proftpd.conf* call s:StarSetf('apachestyle')
110 au BufNewFile,BufRead .htaccess setf apache
111 au BufNewFile,BufRead httpd.conf*,srm.conf*,access.conf*,apache.conf*,apache2.conf*,/etc/apache2/*.conf* call s:StarSetf('apache')
113 " XA65 MOS6510 cross assembler
114 au BufNewFile,BufRead *.a65 setf a65
117 au BufNewFile,BufRead *.am
118 \ if expand("<afile>") !~? 'Makefile.am\>' | setf elf | endif
121 au BufNewFile,BufRead ~/.asoundrc,/usr/share/alsa/alsa.conf,/etc/asound.conf setf alsaconf
124 au BufNewFile,BufRead *.aml setf aml
126 " Arch Inventory file
127 au BufNewFile,BufRead .arch-inventory,=tagging-method setf arch
129 " ART*Enterprise (formerly ART-IM)
130 au BufNewFile,BufRead *.art setf art
133 au BufNewFile,BufRead *.asn,*.asn1 setf asn
135 " Active Server Pages (with Visual Basic Script)
136 au BufNewFile,BufRead *.asa
137 \ if exists("g:filetype_asa") |
138 \ exe "setf " . g:filetype_asa |
143 " Active Server Pages (with Perl or Visual Basic Script)
144 au BufNewFile,BufRead *.asp
145 \ if exists("g:filetype_asp") |
146 \ exe "setf " . g:filetype_asp |
147 \ elseif getline(1) . getline(2) . getline(3) =~? "perlscript" |
153 " Grub (must be before catch *.lst)
154 au BufNewFile,BufRead /boot/grub/menu.lst,/boot/grub/grub.conf,/etc/grub.conf setf grub
156 " Assembly (all kinds)
157 " *.lst is not pure assembly, it has two extra columns (address, byte codes)
158 au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst call s:FTasm()
160 " This function checks for the kind of assembly that is wanted by the user, or
161 " can be detected from the first five lines of the file.
163 " make sure b:asmsyntax exists
164 if !exists("b:asmsyntax")
172 " if b:asmsyntax still isn't set, default to asmsyntax or GNU
174 if exists("g:asmsyntax")
175 let b:asmsyntax = g:asmsyntax
177 let b:asmsyntax = "asm"
181 exe "setf " . b:asmsyntax
184 func! s:FTasmsyntax()
185 " see if file contains any asmsyntax=foo overrides. If so, change
186 " b:asmsyntax appropriately
187 let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4).
189 if head =~ '\sasmsyntax=\S\+\s'
190 let b:asmsyntax = substitute(head, '.*\sasmsyntax=\(\S\+\)\s.*','\1', "")
191 elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library'))
192 let b:asmsyntax = "vmasm"
197 au BufNewFile,BufRead *.mar setf vmasm
200 au BufNewFile,BufRead *.atl,*.as setf atlas
203 au BufNewFile,BufRead *.au3 setf autoit
206 au BufNewFile,BufRead *.ahk setf autohotkey
209 au BufNewFile,BufRead [mM]akefile.am,GNUmakefile.am setf automake
211 " Autotest .at files are actually m4
212 au BufNewFile,BufRead *.at setf m4
215 au BufNewFile,BufRead *.ave setf ave
218 au BufNewFile,BufRead *.awk setf awk
221 au BufNewFile,BufRead *.mch,*.ref,*.imp setf b
223 " BASIC or Visual Basic
224 au BufNewFile,BufRead *.bas call s:FTVB("basic")
226 " Check if one of the first five lines contains "VB_Name". In that case it is
227 " probably a Visual Basic file. Otherwise it's assumed to be "alt" filetype.
229 if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)'
236 " Visual Basic Script (close to Visual Basic)
237 au BufNewFile,BufRead *.vbs,*.dsm,*.ctl setf vb
239 " IBasic file (similar to QBasic)
240 au BufNewFile,BufRead *.iba,*.ibi setf ibasic
242 " FreeBasic file (similar to QBasic)
243 au BufNewFile,BufRead *.fb,*.bi setf freebasic
245 " Batch file for MSDOS.
246 au BufNewFile,BufRead *.bat,*.sys setf dosbatch
247 " *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd.
248 au BufNewFile,BufRead *.cmd
249 \ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif
251 " Batch file for 4DOS
252 au BufNewFile,BufRead *.btm call s:FTbtm()
254 if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm
262 au BufNewFile,BufRead *.bc setf bc
265 au BufNewFile,BufRead *.bdf setf bdf
267 " BibTeX bibliography database file
268 au BufNewFile,BufRead *.bib setf bib
270 " BibTeX Bibliography Style
271 au BufNewFile,BufRead *.bst setf bst
274 au BufNewFile,BufRead named.conf,rndc.conf setf named
277 au BufNewFile,BufRead named.root setf bindzone
278 au BufNewFile,BufRead *.db call s:BindzoneCheck('')
280 func! s:BindzoneCheck(default)
281 if getline(1).getline(2).getline(3).getline(4) =~ '^; <<>> DiG [0-9.]\+ <<>>\|BIND.*named\|$ORIGIN\|$TTL\|IN\s\+SOA'
283 elseif a:default != ''
284 exe 'setf ' . a:default
289 au BufNewFile,BufRead *.bl setf blank
292 au BufNewFile,BufRead *.c call s:FTlpc()
295 if exists("g:lpc_syntax_for_c")
298 if getline(lnum) =~# '^\(//\|inherit\|private\|protected\|nosave\|string\|object\|mapping\|mixed\)'
309 au BufNewFile,BufRead calendar setf calendar
310 au BufNewFile,BufRead */.calendar/*,
311 \*/share/calendar/*/calendar.*,*/share/calendar/calendar.*
312 \ call s:StarSetf('calendar')
315 au BufNewFile,BufRead *.cs setf cs
318 au BufNewFile,BufRead *.toc setf cdrtoc
321 au BufNewFile,BufRead etc/cdrdao.conf,etc/defaults/cdrdao,etc/default/cdrdao,~/.cdrdao setf cdrdaoconf
324 au BufNewFile,BufRead cfengine.conf setf cfengine
326 " Comshare Dimension Definition Language
327 au BufNewFile,BufRead *.cdl setf cdl
330 au BufNewFile,BufRead *.recipe setf conaryrecipe
332 " Controllable Regex Mutilator
333 au BufNewFile,BufRead *.crm setf crm
336 au BufNewFile,BufRead *.cyn setf cynpp
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
347 au BufNewFile,BufRead *.cxx,*.c++,*.C,*.H,*.hh,*.hxx,*.hpp,*.moc,*.tcc,*.inl setf cpp
349 au BufNewFile,BufRead *.cxx,*.c++,*.hh,*.hxx,*.hpp,*.moc,*.tcc,*.inl setf cpp
352 " .h files can be C, Ch C++, ObjC or ObjC++.
353 " Set c_syntax_for_h if you want C, ch_syntax_for_h if you want Ch. ObjC is
354 " detected automatically.
355 au BufNewFile,BufRead *.h call s:FTheader()
358 if match(getline(1, min([line("$"), 200])), '^@\(interface\|end\|class\)') > -1
360 elseif exists("c_syntax_for_h")
362 elseif exists("ch_syntax_for_h")
370 au BufNewFile,BufRead *.chf setf ch
372 " TLH files are C++ headers generated by Visual C++'s #import from typelibs
373 au BufNewFile,BufRead *.tlh setf cpp
375 " Cascading Style Sheets
376 au BufNewFile,BufRead *.css setf css
378 " Century Term Command Scripts (*.cmd too)
379 au BufNewFile,BufRead *.con setf cterm
382 au BufNewFile,BufRead changelog.Debian,changelog.dch,NEWS.Debian,NEWS.dch
385 au BufNewFile,BufRead [cC]hange[lL]og
386 \ if getline(1) =~ '; urgency='
392 au BufNewFile,BufRead NEWS
393 \ if getline(1) =~ '; urgency='
398 au BufNewFile,BufRead *..ch setf chill
400 " Changes for WEB and CWEB or CHILL
401 au BufNewFile,BufRead *.ch call s:FTchange()
403 " This function checks if one of the first ten lines start with a '@'. In
404 " that case it is probably a change file.
405 " If the first line starts with # or ! it's probably a ch file.
406 " If a line has "main", "include", "//" ir "/*" it's probably ch.
407 " Otherwise CHILL is assumed.
411 if getline(lnum)[0] == '@'
415 if lnum == 1 && (getline(1)[0] == '#' || getline(1)[0] == '!')
419 if getline(lnum) =~ "MODULE"
423 if getline(lnum) =~ 'main\s*(\|#\s*include\|//'
433 au BufNewFile,BufRead *.chopro,*.crd,*.cho,*.crdpro,*.chordpro setf chordpro
436 au BufNewFile,BufRead *.dcl,*.icl setf clean
439 au BufNewFile,BufRead *.eni setf cl
442 au BufNewFile,BufRead *.ent call s:FTent()
445 " This function checks for valid cl syntax in the first five lines.
446 " Look for either an opening comment, '#', or a block start, '{".
447 " If not found, assume SGML.
450 let line = getline(lnum)
451 if line =~ '^\s*[#{]'
454 elseif line !~ '^\s*$'
455 " Not a blank line, not a comment, and not a block start,
456 " so doesn't look like valid cl code.
464 " Clipper (or FoxPro; could also be eviews)
465 au BufNewFile,BufRead *.prg
466 \ if exists("g:filetype_prg") |
467 \ exe "setf " . g:filetype_prg |
473 au BufNewFile,BufRead CMakeLists.txt,*.cmake,*.cmake.in setf cmake
476 au BufNewFile,BufRead ~/.cmus/{autosave,rc,command-history,*.theme} setf cmusrc
477 au BufNewFile,BufRead */cmus/{rc,*.theme} setf cmusrc
480 au BufNewFile,BufRead *.cbl,*.cob,*.lib setf cobol
481 " cobol or zope form controller python script? (heuristic)
482 au BufNewFile,BufRead *.cpy
483 \ if getline(1) =~ '^##' |
490 au BufNewFile,BufRead *.atg setf coco
493 au BufNewFile,BufRead *.cfm,*.cfi,*.cfc setf cf
496 au BufNewFile,BufRead configure.in,configure.ac setf config
498 " CUDA Cumpute Unified Device Architecture
499 au BufNewFile,BufRead *.cu setf cuda
501 " WildPackets EtherPeek Decoder
502 au BufNewFile,BufRead *.dcd setf dcd
504 " Enlightenment configuration files
505 au BufNewFile,BufRead *enlightenment/*.cfg setf c
508 au BufNewFile,BufRead *Eterm/*.cfg setf eterm
511 au BufNewFile,BufRead lynx.cfg setf lynx
514 au BufNewFile,BufRead *baseq[2-3]/*.cfg,*id1/*.cfg setf quake
515 au BufNewFile,BufRead *quake[1-3]/*.cfg setf quake
518 au BufNewFile,BufRead *.qc setf c
521 au BufNewFile,BufRead *.cfg setf cfg
523 " Communicating Sequential Processes
524 au BufNewFile,BufRead *.csp,*.fdr setf csp
526 " CUPL logic description and simulation
527 au BufNewFile,BufRead *.pld setf cupl
528 au BufNewFile,BufRead *.si setf cuplsim
531 au BufNewFile,BufRead */debian/control setf debcontrol
533 " Debian Sources.list
534 au BufNewFile,BufRead /etc/apt/sources.list setf debsources
537 au BufNewFile,BufRead denyhosts.conf setf denyhosts
539 " ROCKLinux package description
540 au BufNewFile,BufRead *.desc setf desc
543 au BufNewFile,BufRead *.d setf d
546 au BufNewFile,BufRead *.desktop,.directory setf desktop
549 au BufNewFile,BufRead dict.conf,.dictrc setf dictconf
552 au BufNewFile,BufRead dictd.conf setf dictdconf
555 au BufNewFile,BufRead *.diff,*.rej,*.patch setf diff
558 au BufNewFile,BufRead .dir_colors,/etc/DIR_COLORS setf dircolors
560 " Diva (with Skill) or InstallShield
561 au BufNewFile,BufRead *.rul
562 \ if getline(1).getline(2).getline(3).getline(4).getline(5).getline(6) =~? 'InstallShield' |
568 " DCL (Digital Command Language - vms) or DNS zone file
569 au BufNewFile,BufRead *.com call s:BindzoneCheck('dcl')
572 au BufNewFile,BufRead *.dot setf dot
575 au BufNewFile,BufRead *.lid setf dylanlid
577 " Dylan - intr files (melange)
578 au BufNewFile,BufRead *.intr setf dylanintr
581 au BufNewFile,BufRead *.dylan setf dylan
583 " Microsoft Module Definition
584 au BufNewFile,BufRead *.def setf def
587 au BufNewFile,BufRead *.drac,*.drc,*lvs,*lpe setf dracula
590 au BufNewFile,BufRead *.dsl setf dsl
592 " DTD (Document Type Definition for XML)
593 au BufNewFile,BufRead *.dtd setf dtd
595 " EDIF (*.edf,*.edif,*.edn,*.edo)
596 au BufNewFile,BufRead *.ed\(f\|if\|n\|o\) setf edif
598 " Embedix Component Description
599 au BufNewFile,BufRead *.ecd setf ecd
602 au BufNewFile,BufRead *.e,*.E call s:FTe()
604 " Elinks configuration
605 au BufNewFile,BufRead */etc/elinks.conf,*/.elinks/elinks.conf setf elinks
609 while n < 100 && n < line("$")
610 if getline(n) =~ "^\\s*\\(<'\\|'>\\)\\s*$"
619 " ERicsson LANGuage; Yaws is erlang too
620 au BufNewFile,BufRead *.erl,*.yaws setf erlang
622 " Elm Filter Rules file
623 au BufNewFile,BufRead filter-rules setf elmfilt
626 au BufNewFile,BufRead *esmtprc setf esmtprc
629 au BufNewFile,BufRead *.ec,*.EC setf esqlc
632 au BufNewFile,BufRead *.strl setf esterel
635 au BufNewFile,BufRead *.csc setf csc
638 au BufNewFile,BufRead exim.conf setf exim
641 au BufNewFile,BufRead *.exp setf expect
644 au BufNewFile,BufRead exports setf exports
647 au BufNewFile,BufRead *.factor setf factor
650 au BufNewFile,BufRead .fetchmailrc setf fetchmail
653 au BufNewFile,BufRead *.wiki setf flexwiki
656 au BufNewFile,BufRead *.fex,*.focexec setf focexec
658 " Focus Master file (but not for auto.master)
659 au BufNewFile,BufRead auto.master setf conf
660 au BufNewFile,BufRead *.mas,*.master setf master
663 au BufNewFile,BufRead *.fs,*.ft setf forth
666 au BufNewFile,BufRead *.frt setf reva
670 au BufNewFile,BufRead *.F,*.FOR,*.FPP,*.FTN,*.F77,*.F90,*.F95 setf fortran
672 au BufNewFile,BufRead *.f,*.for,*.fortran,*.fpp,*.ftn,*.f77,*.f90,*.f95 setf fortran
675 au BufNewFile,BufRead fstab,mtab setf fstab
678 au BufNewFile,BufRead .gdbinit setf gdb
681 au BufNewFile,BufRead *.mo,*.gdmo setf gdmo
684 au BufNewFile,BufRead *.ged setf gedcom
687 autocmd BufNewFile,BufRead *.git/COMMIT_EDITMSG setf gitcommit
688 autocmd BufNewFile,BufRead *.git/config,.gitconfig setf gitconfig
689 autocmd BufNewFile,BufRead .msg.[0-9]*
690 \ if getline(1) =~ '^From.*# This line is ignored.$' |
691 \ setf gitsendemail |
695 au BufNewFile,BufRead gkrellmrc,gkrellmrc_? setf gkrellmrc
697 " GP scripts (2.0 and onward)
698 au BufNewFile,BufRead *.gp,.gprc setf gp
701 au BufNewFile,BufRead */.gnupg/options setf gpg
702 au BufNewFile,BufRead */.gnupg/gpg.conf setf gpg
703 au BufNewFile,BufRead /usr/**/gnupg/options.skel setf gpg
706 au BufNewFile,BufRead *.gpi setf gnuplot
709 au BufNewFile,BufRead *.gs setf grads
712 au BufNewFile,BufRead *.gretl setf gretl
715 au BufNewFile,BufRead *.groovy setf groovy
718 au BufNewFile,BufRead *.gsp setf gsp
721 au BufNewFile,BufRead /etc/group setf group
724 au BufNewFile,BufRead .gtkrc,gtkrc setf gtkrc
726 " Hamster Classic | Playground files
727 au BufNewFile,BufRead *.hsc,*.hsm setf hamster
730 au BufNewFile,BufRead *.hs setf haskell
731 au BufNewFile,BufRead *.lhs setf lhaskell
732 au BufNewFile,BufRead *.chs setf chaskell
735 au BufNewFile,BufRead *.vc,*.ev,*.rs,*.sum,*.errsum setf hercules
738 au BufNewFile,BufRead *.hex,*.h32 setf hex
740 " Tilde (must be before HTML)
741 au BufNewFile,BufRead *.t.html setf tilde
743 " HTML (.shtml and .stm for server side)
744 au BufNewFile,BufRead *.html,*.htm,*.shtml,*.stm call s:FThtml()
746 " Distinguish between HTML, XHTML and Django
749 while n < 10 && n < line("$")
750 if getline(n) =~ '\<DTD\s\+XHTML\s'
754 if getline(n) =~ '{%\s*\(extends\|block\)\>'
763 " HTML with Ruby - eRuby
764 au BufNewFile,BufRead *.erb,*.rhtml setf eruby
767 au BufNewFile,BufRead *.html.m4 setf htmlm4
769 " HTML Cheetah template
770 au BufNewFile,BufRead *.tmpl setf htmlcheetah
773 au BufNewFile,BufRead /etc/host.conf setf hostconf
776 au BufNewFile,BufRead *.hb setf hb
779 au BufNewFile,BufRead *.icn setf icon
781 " IDL (Interface Description Language)
782 au BufNewFile,BufRead *.idl call s:FTidl()
784 " Distinguish between standard IDL and MS-IDL
787 while n < 50 && n < line("$")
788 if getline(n) =~ '^\s*import\s\+"\(unknwn\|objidl\)\.idl"'
797 " Microsoft IDL (Interface Description Language) Also *.idl
798 " MOF = WMI (Windows Management Instrumentation) Managed Object Format
799 au BufNewFile,BufRead *.odl,*.mof setf msidl
802 au BufNewFile,BufRead */.icewm/menu setf icemenu
804 " Indent profile (must come before IDL *.pro!)
805 au BufNewFile,BufRead .indent.pro setf indent
806 au BufNewFile,BufRead indent.pro call s:ProtoCheck('indent')
808 " IDL (Interactive Data Language)
809 au BufNewFile,BufRead *.pro call s:ProtoCheck('idlang')
811 " Distinguish between "default" and Cproto prototype file. */
812 func! s:ProtoCheck(default)
813 " Cproto files have a comment in the first line and a function prototype in
814 " the second line, it always ends in ";". Indent files may also have
815 " comments, thus we can't match comments to see the difference.
816 if getline(2) =~ ';$'
819 exe 'setf ' . a:default
825 au BufNewFile,BufRead indentrc setf indentrc
828 au BufNewFile,BufRead *.inf,*.INF setf inform
831 au BufNewFile,BufRead /etc/initng/**/*.i,*.ii setf initng
834 au BufNewFile,BufRead ipf.conf,ipf6.conf,ipf.rules setf ipfilter
836 " Informix 4GL (source - canonical, include file, I4GL+M4 preproc.)
837 au BufNewFile,BufRead *.4gl,*.4gh,*.m4gl setf fgl
839 " .INI file for MSDOS
840 au BufNewFile,BufRead *.ini setf dosini
843 au BufNewFile,BufRead inittab setf inittab
846 au BufNewFile,BufRead *.iss setf iss
849 au BufNewFile,BufRead *.jal,*.JAL setf jal
852 au BufNewFile,BufRead *.jpl,*.jpr setf jam
855 au BufNewFile,BufRead *.java,*.jav setf java
858 au BufNewFile,BufRead *.jj,*.jjt setf javacc
860 " JavaScript, ECMAScript
861 au BufNewFile,BufRead *.js,*.javascript,*.es setf javascript
864 au BufNewFile,BufRead *.jsp setf jsp
866 " Java Properties resource file (note: doesn't catch font.properties.pl)
867 au BufNewFile,BufRead *.properties,*.properties_??,*.properties_??_?? setf jproperties
868 au BufNewFile,BufRead *.properties_??_??_* call s:StarSetf('jproperties')
871 au BufNewFile,BufRead *.clp setf jess
874 au BufNewFile,BufRead *.jgr setf jgraph
877 au BufNewFile,BufRead *.kix setf kix
880 au BufNewFile,BufRead *.k setf kwt
883 au BufNewFile,BufRead *.ks setf kscript
886 au BufNewFile,BufRead Kconfig,Kconfig.debug setf kconfig
889 au BufNewFile,BufRead *.ace,*.ACE setf lace
892 au BufNewFile,BufRead *.latte,*.lte setf latte
895 au BufNewFile,BufRead /etc/limits setf limits
897 " LambdaProlog (*.mod too, see Modsim)
898 au BufNewFile,BufRead *.sig setf lprolog
901 au BufNewFile,BufRead *.ldif setf ldif
904 au BufNewFile,BufRead *.ld setf ld
907 au BufNewFile,BufRead *.lex,*.l setf lex
910 au BufNewFile,BufRead /etc/libao.conf,*/.libao setf libao
913 au BufNewFile,BufRead /etc/sensors.conf setf sensors
916 au BufNewFile,BufRead lftp.conf,.lftprc,*lftp/rc setf lftp
918 " Lifelines (or Lex for C++!)
919 au BufNewFile,BufRead *.ll setf lifelines
922 au BufNewFile,BufRead lilo.conf* call s:StarSetf('lilo')
924 " Lisp (*.el = ELisp, *.cl = Common Lisp, *.jl = librep Lisp)
926 au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,*.L,.emacs,.sawfishrc setf lisp
928 au BufNewFile,BufRead *.lsp,*.lisp,*.el,*.cl,*.jl,.emacs,.sawfishrc setf lisp
931 " SBCL implementation of Common Lisp
932 au BufNewFile,BufRead sbclrc,.sbclrc setf lisp
935 au BufNewFile,BufRead *.lite,*.lt setf lite
938 au BufNewFile,BufRead */LiteStep/*/*.rc setf litestep
941 au BufNewFile,BufRead /etc/login.access setf loginaccess
944 au BufNewFile,BufRead /etc/login.defs setf logindefs
947 au BufNewFile,BufRead *.lgt setf logtalk
950 au BufNewFile,BufRead *.lot,*.lotos setf lotos
953 au BufNewFile,BufRead *.lou,*.lout setf lout
956 au BufNewFile,BufRead *.lua setf lua
958 " Linden Scripting Language (Second Life)
959 au BufNewFile,BufRead *.lsl setf lsl
961 " Lynx style file (or LotusScript!)
962 au BufNewFile,BufRead *.lss setf lss
965 au BufNewFile,BufRead *.m4
966 \ if expand("<afile>") !~? 'html.m4$\|fvwm2rc' | setf m4 | endif
969 au BufNewFile,BufRead *.mgp setf mgp
971 " Mail (for Elm, trn, mutt, muttng, rn, slrn)
972 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
975 au BufNewFile,BufRead /etc/mail/aliases,/etc/aliases setf mailaliases
977 " Mailcap configuration file
978 au BufNewFile,BufRead .mailcap,mailcap setf mailcap
981 au BufNewFile,BufRead *[mM]akefile,*.mk,*.mak,*.dsp setf make
984 au BufNewFile,BufRead *.ist,*.mst setf ist
987 au BufNewFile,BufRead *.man setf man
990 au BufNewFile,BufRead /etc/man.conf,man.config setf manconf
993 au BufNewFile,BufRead *.mv,*.mpl,*.mws setf maple
996 au BufNewFile,BufRead *.mason,*.mhtml setf mason
998 " Matlab or Objective C
999 au BufNewFile,BufRead *.m call s:FTm()
1004 let line = getline(n)
1005 if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)'
1013 if line =~ '^\s*(\*'
1019 if exists("g:filetype_m")
1020 exe "setf " . g:filetype_m
1026 " Mathematica notebook
1027 au BufNewFile,BufRead *.nb setf mma
1029 " Maya Extension Language
1030 au BufNewFile,BufRead *.mel setf mel
1033 au BufNewFile,BufRead /var/log/messages,/var/log/messages.*[0-9] setf messages
1036 au BufNewFile,BufRead *.mf setf mf
1039 au BufNewFile,BufRead *.mp setf mp
1042 au BufNewFile,BufRead *.mgl setf mgl
1044 " MMIX or VMS makefile
1045 au BufNewFile,BufRead *.mms call s:FTmms()
1047 " Symbian meta-makefile definition (MMP)
1048 au BufNewFile,BufRead *.mmp setf mmp
1053 let line = getline(n)
1054 if line =~ '^\s*\(%\|//\)' || line =~ '^\*'
1068 " Modsim III (or LambdaProlog)
1069 au BufNewFile,BufRead *.mod
1070 \ if getline(1) =~ '\<module\>' |
1077 au BufNewFile,BufRead *.m2,*.DEF,*.MOD,*.md,*.mi setf modula2
1079 " Modula 3 (.m3, .i3, .mg, .ig)
1080 au BufNewFile,BufRead *.[mi][3g] setf modula3
1083 au BufNewFile,BufRead *.isc,*.monk,*.ssc,*.tsc setf monk
1086 au BufNewFile,BufRead *.moo setf moo
1089 au BufNewFile,BufRead /etc/modules.conf,/etc/conf.modules setf modconf
1090 au BufNewFile,BufRead /etc/modutils/*
1091 \ if executable(expand("<afile>")) != 1
1092 \| call s:StarSetf('modconf')
1096 au BufNewFile,BufRead mplayer.conf,*/.mplayer/config setf mplayerconf
1099 au BufNewFile,BufRead *.s19,*.s28,*.s37 setf srec
1102 au BufNewFile,BufRead mrxvtrc,.mrxvtrc setf mrxvtrc
1105 au BufNewFile,BufRead *.msql setf msql
1108 au BufNewFile,BufRead *.mysql setf mysql
1111 au BufNewFile,BufRead *.rc setf rc
1114 au BufRead,BufNewFile *.mu setf mupad
1117 au BufNewFile,BufRead *.mush setf mush
1119 " Mutt setup file (also for Muttng)
1120 au BufNewFile,BufRead Mutt{ng,}rc setf muttrc
1123 au BufNewFile,BufRead /etc/nanorc,.nanorc setf nanorc
1125 " Nastran input/DMAP
1126 "au BufNewFile,BufRead *.dat setf nastran
1129 au BufNewFile,BufRead *.NS[ACGLMNPS] setf natural
1132 au BufNewFile,BufRead .netrc setf netrc
1134 " Novell netware batch files
1135 au BufNewFile,BufRead *.ncf setf ncf
1137 " Nroff/Troff (*.ms and *.t are checked below)
1138 au BufNewFile,BufRead *.me
1139 \ if expand("<afile>") != "read.me" && expand("<afile>") != "click.me" |
1142 au BufNewFile,BufRead *.tr,*.nr,*.roff,*.tmac,*.mom setf nroff
1143 au BufNewFile,BufRead *.[1-9] call s:FTnroff()
1145 " This function checks if one of the first five lines start with a dot. In
1146 " that case it is probably an nroff file: 'filetype' is set and 1 is returned.
1148 if getline(1)[0] . getline(2)[0] . getline(3)[0] . getline(4)[0] . getline(5)[0] =~ '\.'
1155 " Nroff or Objective C++
1156 au BufNewFile,BufRead *.mm call s:FTmm()
1161 let line = getline(n)
1162 if line =~ '^\s*\(#\s*\(include\|import\)\>\|/\*\)'
1172 au BufNewFile,BufRead *.nqc setf nqc
1175 au BufNewFile,BufRead *.nsi setf nsis
1178 au BufNewFile,BufRead *.ml,*.mli,*.mll,*.mly setf ocaml
1181 au BufNewFile,BufRead *.occ setf occam
1184 au BufNewFile,BufRead *.xom,*.xin setf omnimark
1187 au BufNewFile,BufRead *.or setf openroad
1190 au BufNewFile,BufRead *.[Oo][Pp][Ll] setf opl
1192 " Oracle config file
1193 au BufNewFile,BufRead *.ora setf ora
1195 " Packet filter conf
1196 au BufNewFile,BufRead pf.conf setf pf
1199 au BufNewFile,BufRead /etc/pam.conf setf pamconf
1202 au BufNewFile,BufRead *.papp,*.pxml,*.pxsl setf papp
1205 au BufNewFile,BufRead /etc/passwd,/etc/shadow,/etc/shadow- setf passwd
1208 au BufNewFile,BufRead *.pas setf pascal
1210 " Delphi project file
1211 au BufNewFile,BufRead *.dpr setf pascal
1214 au BufNewFile,BufRead *.pdf setf pdf
1217 if has("fname_case")
1218 au BufNewFile,BufRead *.pl,*.PL call s:FTpl()
1220 au BufNewFile,BufRead *.pl call s:FTpl()
1222 au BufNewFile,BufRead *.plx setf perl
1225 if exists("g:filetype_pl")
1226 exe "setf " . g:filetype_pl
1228 " recognize Prolog by specific text in the first non-empty line
1229 " require a blank after the '%' because Perl uses "%list" and "%translate"
1230 let l = getline(nextnonblank(1))
1231 if l =~ '\<prolog\>' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-'
1240 au BufNewFile,BufRead *.pm
1241 \ if getline(1) =~ "XPM2" |
1243 \ elseif getline(1) =~ "XPM" |
1250 au BufNewFile,BufRead *.pod setf pod
1252 " Php, php3, php4, etc.
1253 " Also Phtml (was used for PHP 2 in the past)
1254 " Also .ctp for Cake template file
1255 au BufNewFile,BufRead *.php,*.php\d,*.phtml,*.ctp setf php
1258 au BufNewFile,BufRead *.pike,*.lpc,*.ulpc,*.pmod setf pike
1261 au BufNewFile,BufRead */etc/pinforc,*/.pinforc setf pinfo
1263 " Palm Resource compiler
1264 au BufNewFile,BufRead *.rcp setf pilrc
1267 au BufNewFile,BufRead .pinerc,pinerc,.pinercex,pinercex setf pine
1269 " PL/M (also: *.inp)
1270 au BufNewFile,BufRead *.plm,*.p36,*.pac setf plm
1273 au BufNewFile,BufRead *.pls,*.plsql setf plsql
1276 au BufNewFile,BufRead *.plp setf plp
1278 " PO and PO template (GNU gettext)
1279 au BufNewFile,BufRead *.po,*.pot setf po
1281 " Postfix main config
1282 au BufNewFile,BufRead main.cf setf pfmain
1284 " PostScript (+ font files, encapsulated PostScript, Adobe Illustrator)
1285 au BufNewFile,BufRead *.ps,*.pfa,*.afm,*.eps,*.epsf,*.epsi,*.ai setf postscr
1287 " PostScript Printer Description
1288 au BufNewFile,BufRead *.ppd setf ppd
1291 au BufNewFile,BufRead *.pov setf pov
1293 " Povray configuration
1294 au BufNewFile,BufRead .povrayrc setf povini
1296 " Povray, PHP or assembly
1297 au BufNewFile,BufRead *.inc call s:FTinc()
1300 if exists("g:filetype_inc")
1301 exe "setf " . g:filetype_inc
1303 let lines = getline(1).getline(2).getline(3)
1304 if lines =~? "perlscript"
1306 elseif lines =~ "<%"
1308 elseif lines =~ "<?"
1311 call s:FTasmsyntax()
1312 if exists("b:asmsyntax")
1313 exe "setf " . b:asmsyntax
1321 " Printcap and Termcap
1322 au BufNewFile,BufRead *printcap
1323 \ let b:ptcap_type = "print" | setf ptcap
1324 au BufNewFile,BufRead *termcap
1325 \ let b:ptcap_type = "term" | setf ptcap
1328 "au BufNewFile,BufRead *.g setf antrl
1329 au BufNewFile,BufRead *.g setf pccts
1332 au BufNewFile,BufRead *.it,*.ih setf ppwiz
1335 au BufNewFile,BufRead *.pc setf proc
1337 " Privoxy actions file
1338 au BufNewFile,BufRead *.action setf privoxy
1341 au BufNewFile,BufRead .procmail,.procmailrc setf procmail
1344 au BufNewFile,BufRead *.w call s:FTprogress_cweb()
1346 func! s:FTprogress_cweb()
1347 if exists("g:filetype_w")
1348 exe "setf " . g:filetype_w
1351 if getline(1) =~ '&ANALYZE' || getline(3) =~ '&GLOBAL-DEFINE'
1358 " Progress or assembly
1359 au BufNewFile,BufRead *.i call s:FTprogress_asm()
1361 func! s:FTprogress_asm()
1362 if exists("g:filetype_i")
1363 exe "setf " . g:filetype_i
1366 " This function checks for an assembly comment the first ten lines.
1367 " If not found, assume Progress.
1369 while lnum <= 10 && lnum < line('$')
1370 let line = getline(lnum)
1371 if line =~ '^\s*;' || line =~ '^\*'
1374 elseif line !~ '^\s*$' || line =~ '^/\*'
1375 " Not an empty line: Doesn't look like valid assembly code.
1376 " Or it looks like a Progress /* comment
1384 " Progress or Pascal
1385 au BufNewFile,BufRead *.p call s:FTprogress_pascal()
1387 func! s:FTprogress_pascal()
1388 if exists("g:filetype_p")
1389 exe "setf " . g:filetype_p
1392 " This function checks for valid Pascal syntax in the first ten lines.
1393 " Look for either an opening comment or a program start.
1394 " If not found, assume Progress.
1396 while lnum <= 10 && lnum < line('$')
1397 let line = getline(lnum)
1398 if line =~ '^\s*\(program\|unit\|procedure\|function\|const\|type\|var\)\>'
1399 \ || line =~ '^\s*{' || line =~ '^\s*(\*'
1402 elseif line !~ '^\s*$' || line =~ '^/\*'
1403 " Not an empty line: Doesn't look like valid Pascal code.
1404 " Or it looks like a Progress /* comment
1413 " Software Distributor Product Specification File (POSIX 1387.2-1995)
1414 au BufNewFile,BufRead *.psf setf psf
1415 au BufNewFile,BufRead INDEX,INFO
1416 \ if getline(1) =~ '^\s*\(distribution\|installed_software\|root\|bundle\|product\)\s*$' |
1421 au BufNewFile,BufRead *.pdb setf prolog
1424 au BufNewFile,BufRead *.pml setf promela
1427 au BufNewFile,BufRead /etc/protocols setf protocols
1430 au BufNewFile,BufRead *.pyx,*.pxd setf pyrex
1433 au BufNewFile,BufRead *.py,*.pyw setf python
1436 au BufNewFile,BufRead *.rad,*.mat setf radiance
1438 " Ratpoison config/command files
1439 au BufNewFile,BufRead .ratpoisonrc,ratpoisonrc setf ratpoison
1442 au BufNewFile,BufRead *\,v setf rcs
1445 au BufNewFile,BufRead .inputrc,inputrc setf readline
1447 " Registry for MS-Windows
1448 au BufNewFile,BufRead *.reg
1449 \ if getline(1) =~? '^REGEDIT[0-9]*\s*$\|^Windows Registry Editor Version \d*\.\d*\s*$' | setf registry | endif
1451 " Renderman Interface Bytestream
1452 au BufNewFile,BufRead *.rib setf rib
1455 au BufNewFile,BufRead *.rexx,*.rex,*.jrexx,*.rxj,*.orx setf rexx
1458 if has("fname_case")
1459 au BufNewFile,BufRead *.s,*.S setf r
1461 au BufNewFile,BufRead *.s setf r
1465 if has("fname_case")
1466 au BufNewFile,BufRead *.rd,*.Rd setf rhelp
1468 au BufNewFile,BufRead *.rd setf rhelp
1472 if has("fname_case")
1473 au BufNewFile,BufRead *.Rnw,*.rnw,*.Snw,*.snw setf rnoweb
1475 au BufNewFile,BufRead *.rnw,*.snw setf rnoweb
1479 au BufNewFile,BufRead *.r,*.R call s:FTr()
1482 let max = line("$") > 50 ? 50 : line("$")
1484 for n in range(1, max)
1485 " Rebol is easy to recognize, check for that first
1486 if getline(n) =~? '\<REBOL\>'
1492 for n in range(1, max)
1494 if getline(n) =~ '^\s*#'
1498 " Rexx has /* comments */
1499 if getline(n) =~ '^\s*/\*'
1505 " Nothing recognized, assume Rexx
1510 au BufNewFile,BufRead .reminders* call s:StarSetf('remind')
1513 au BufNewFile,BufRead resolv.conf setf resolv
1516 au BufNewFile,BufRead *.rnc setf rnc
1519 au BufNewFile,BufRead *.rpl setf rpl
1522 au BufNewFile,BufRead robots.txt setf robots
1525 au BufNewFile,BufRead *.x setf rpcgen
1527 " reStructuredText Documentation Format
1528 au BufNewFile,BufRead *.rst setf rst
1531 au BufNewFile,BufRead *.rtf setf rtf
1534 au BufNewFile,BufRead *.rb,*.rbw,*.gem,*.gemspec setf ruby
1537 au BufNewFile,BufRead *.builder,*.rxml,*.rjs setf ruby
1539 " Rantfile and Rakefile is like Ruby
1540 au BufNewFile,BufRead [rR]antfile,*.rant,[rR]akefile,*.rake setf ruby
1542 " S-lang (or shader language!)
1543 au BufNewFile,BufRead *.sl setf slang
1546 au BufNewFile,BufRead smb.conf setf samba
1549 au BufNewFile,BufRead *.sas setf sas
1552 au BufNewFile,BufRead *.sa setf sather
1555 au BufNewFile,BufRead *.sci,*.sce setf scilab
1557 " SD: Streaming Descriptors
1558 au BufNewFile,BufRead *.sd setf sd
1561 au BufNewFile,BufRead *.sdl,*.pr setf sdl
1564 au BufNewFile,BufRead *.sed setf sed
1567 au BufNewFile,BufRead *.siv setf sieve
1570 au BufNewFile,BufRead sendmail.cf setf sm
1572 " Sendmail .mc files are actually m4
1573 au BufNewFile,BufRead *.mc setf m4
1576 au BufNewFile,BufRead /etc/services setf services
1578 " Service Location config
1579 au BufNewFile,BufRead /etc/slp.conf setf slpconf
1581 " Service Location registration
1582 au BufNewFile,BufRead /etc/slp.reg setf slpreg
1584 " Service Location SPI
1585 au BufNewFile,BufRead /etc/slp.spi setf slpspi
1588 au BufNewFile,BufRead /etc/serial.conf setf setserial
1591 au BufNewFile,BufRead *.sgm,*.sgml
1592 \ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'linuxdoc' |
1594 \ elseif getline(1) =~ '<!DOCTYPE.*DocBook' || getline(2) =~ '<!DOCTYPE.*DocBook' |
1595 \ let b:docbk_type="sgml" |
1602 au BufNewFile,BufRead *.decl,*.dcl,*.dec
1603 \ if getline(1).getline(2).getline(3) =~? '^<!SGML' |
1608 au BufNewFile,BufRead catalog setf catalog
1609 au BufNewFile,BufRead sgml.catalog* call s:StarSetf('catalog')
1611 " Shell scripts (sh, ksh, bash, bash2, csh); Allow .profile_foo etc.
1612 " Gentoo ebuilds are actually bash scripts
1613 au BufNewFile,BufRead .bashrc*,bashrc,bash.bashrc,.bash_profile*,.bash_logout*,*.bash,*.ebuild call SetFileTypeSH("bash")
1614 au BufNewFile,BufRead .kshrc*,*.ksh call SetFileTypeSH("ksh")
1615 au BufNewFile,BufRead /etc/profile,.profile*,*.sh,*.env call SetFileTypeSH(getline(1))
1617 " Also called from scripts.vim.
1618 func! SetFileTypeSH(name)
1619 if expand("<amatch>") =~ g:ft_ignore_pat
1622 if a:name =~ '\<ksh\>'
1623 let b:is_kornshell = 1
1624 if exists("b:is_bash")
1627 if exists("b:is_sh")
1630 elseif exists("g:bash_is_sh") || a:name =~ '\<bash\>' || a:name =~ '\<bash2\>'
1632 if exists("b:is_kornshell")
1633 unlet b:is_kornshell
1635 if exists("b:is_sh")
1638 elseif a:name =~ '\<sh\>'
1640 if exists("b:is_kornshell")
1641 unlet b:is_kornshell
1643 if exists("b:is_bash")
1647 call SetFileTypeShell("sh")
1650 " For shell-like file types, check for an "exec" command hidden in a comment,
1652 " Also called from scripts.vim, thus can't be local to this script.
1653 func! SetFileTypeShell(name)
1654 if expand("<amatch>") =~ g:ft_ignore_pat
1658 while l < 20 && l < line("$") && getline(l) =~ '^\s*\(#\|$\)'
1659 " Skip empty and comment lines.
1662 if l < line("$") && getline(l) =~ '\s*exec\s' && getline(l - 1) =~ '^\s*#.*\\$'
1663 " Found an "exec" line after a comment with continuation
1664 let n = substitute(getline(l),'\s*exec\s\+\([^ ]*/\)\=', '', '')
1665 if n =~ '\<tclsh\|\<wish'
1670 exe "setf " . a:name
1674 au BufNewFile,BufRead .tcshrc*,*.tcsh,tcsh.tcshrc,tcsh.login call SetFileTypeShell("tcsh")
1676 " csh scripts, but might also be tcsh scripts (on some systems csh is tcsh)
1677 au BufNewFile,BufRead .login*,.cshrc*,csh.cshrc,csh.login,csh.logout,*.csh,.alias call s:CSH()
1680 if exists("g:filetype_csh")
1681 call SetFileTypeShell(g:filetype_csh)
1682 elseif &shell =~ "tcsh"
1683 call SetFileTypeShell("tcsh")
1685 call SetFileTypeShell("csh")
1690 au BufNewFile,BufRead .zprofile,/etc/zprofile,.zfbfmarks setf zsh
1691 au BufNewFile,BufRead .zsh*,.zlog*,.zcompdump* call s:StarSetf('zsh')
1694 au BufNewFile,BufRead *.scm,*.ss setf scheme
1697 au BufNewFile,BufRead .screenrc,screenrc setf screen
1700 au BufNewFile,BufRead *.sim setf simula
1703 au BufNewFile,BufRead *.sin,*.s85 setf sinda
1706 au BufNewFile,BufRead *.sst,*.ssm,*.ssi,*.-sst,*._sst setf sisu
1707 au BufNewFile,BufRead *.sst.meta,*.-sst.meta,*._sst.meta setf sisu
1710 au BufNewFile,BufRead *.il,*.ils,*.cdf setf skill
1713 au BufNewFile,BufRead .slrnrc setf slrnrc
1714 au BufNewFile,BufRead *.score setf slrnsc
1716 " Smalltalk (and TeX)
1717 au BufNewFile,BufRead *.st setf st
1718 au BufNewFile,BufRead *.cls
1719 \ if getline(1) =~ '^%' |
1726 au BufNewFile,BufRead *.tpl setf smarty
1729 au BufNewFile,BufRead *.smil
1730 \ if getline(1) =~ '<?\s*xml.*?>' |
1736 " SMIL or SNMP MIB file
1737 au BufNewFile,BufRead *.smi
1738 \ if getline(1) =~ '\<smil\>' |
1745 au BufNewFile,BufRead *.smt,*.smith setf smith
1747 " Snobol4 and spitbol
1748 au BufNewFile,BufRead *.sno,*.spt setf snobol4
1751 au BufNewFile,BufRead *.mib,*.my setf mib
1753 " Snort Configuration
1754 au BufNewFile,BufRead *.hog,snort.conf,vision.conf setf hog
1755 au BufNewFile,BufRead *.rules call s:FTRules()
1757 let s:ft_rules_udev_rules_pattern = '^\s*\cudev_rules\s*=\s*"\([^"]\{-1,}\)/*".*'
1760 let config_lines = readfile('/etc/udev/udev.conf')
1761 catch /^Vim\%((\a\+)\)\=:E484/
1765 for line in config_lines
1766 if line =~ s:ft_rules_udev_rules_pattern
1767 let udev_rules = substitute(line, s:ft_rules_udev_rules_pattern, '\1', "")
1768 if expand('<amatch>:p:h') == udev_rules
1779 au BufNewFile,BufRead *.spec setf spec
1781 " Speedup (AspenTech plant simulator)
1782 au BufNewFile,BufRead *.speedup,*.spdata,*.spd setf spup
1785 au BufNewFile,BufRead *.ice setf slice
1788 au BufNewFile,BufRead *.sp,*.spice setf spice
1791 au BufNewFile,BufRead *.spy,*.spi setf spyce
1794 au BufNewFile,BufRead squid.conf setf squid
1796 " SQL for Oracle Designer
1797 au BufNewFile,BufRead *.tyb,*.typ,*.tyc,*.pkb,*.pks setf sql
1800 au BufNewFile,BufRead *.sql call s:SQL()
1803 if exists("g:filetype_sql")
1804 exe "setf " . g:filetype_sql
1811 au BufNewFile,BufRead *.sqlj setf sqlj
1814 au BufNewFile,BufRead *.sqr,*.sqi setf sqr
1816 " OpenSSH configuration
1817 au BufNewFile,BufRead ssh_config,*/.ssh/config setf sshconfig
1819 " OpenSSH server configuration
1820 au BufNewFile,BufRead sshd_config setf sshdconfig
1823 au BufNewFile,BufRead *.ado,*.class,*.do,*.imata,*.mata setf stata
1826 au BufNewFile,BufRead *.hlp,*.ihlp,*.smcl setf smcl
1829 au BufNewFile,BufRead *.stp setf stp
1832 au BufNewFile,BufRead *.sml setf sml
1834 " Sratus VOS command macro
1835 au BufNewFile,BufRead *.cm setf voscm
1838 au BufNewFile,BufRead /etc/sysctl.conf setf sysctl
1841 au BufNewFile,BufRead /etc/sudoers,sudoers.tmp setf sudoers
1843 " If the file has an extension of 't' and is in a directory 't' then it is
1844 " almost certainly a Perl test file.
1845 " If the first line starts with '#' and contains 'perl' it's probably a Perl
1847 " (Slow test) If a file contains a 'use' statement then it is almost certainly
1850 if expand("%:e") == 't' && expand("%:p:h:t") == 't'
1854 if getline(1)[0] == '#' && getline(1) =~ 'perl'
1858 if search('^use\s\s*\k', 'nc', 30)
1865 " Tads (or Nroff or Perl test file)
1866 au BufNewFile,BufRead *.t
1867 \ if !s:FTnroff() && !s:FTperl() | setf tads | endif
1870 au BufNewFile,BufRead tags setf tags
1873 au BufNewFile,BufRead *.tak setf tak
1876 au BufNewFile,BufRead *.tcl,*.tk,*.itcl,*.itk,*.jacl setf tcl
1879 au BufNewFile,BufRead *.tli setf tli
1882 au BufNewFile,BufRead *.slt setf tsalt
1885 au BufNewFile,BufRead *.ti setf terminfo
1888 au BufNewFile,BufRead *.latex,*.sty,*.dtx,*.ltx,*.bbl setf tex
1889 au BufNewFile,BufRead *.tex call s:FTtex()
1891 " Choose context, plaintex, or tex (LaTeX) based on these rules:
1892 " 1. Check the first line of the file for "%&<format>".
1893 " 2. Check the first 1000 non-comment lines for LaTeX or ConTeXt keywords.
1894 " 3. Default to "latex" or to g:tex_flavor, can be set in user's vimrc.
1896 let firstline = getline(1)
1897 if firstline =~ '^%&\s*\a\+'
1898 let format = tolower(matchstr(firstline, '\a\+'))
1899 let format = substitute(format, 'pdf', '', '')
1901 let format = 'plain'
1904 " Default value, may be changed later:
1905 let format = exists("g:tex_flavor") ? g:tex_flavor : 'plain'
1906 " Save position, go to the top of the file, find first non-comment line.
1907 let save_cursor = getpos('.')
1909 let firstNC = search('^\s*[^[:space:]%]', 'c', 1000)
1910 if firstNC " Check the next thousand lines for a LaTeX or ConTeXt keyword.
1911 let lpat = 'documentclass\>\|usepackage\>\|begin{\|newcommand\>\|renewcommand\>'
1912 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\>'
1913 let kwline = search('^\s*\\\%(' . lpat . '\)\|^\s*\\\(' . cpat . '\)',
1914 \ 'cnp', firstNC + 1000)
1915 if kwline == 1 " lpat matched
1916 let format = 'latex'
1917 elseif kwline == 2 " cpat matched
1918 let format = 'context'
1919 endif " If neither matched, keep default set above.
1920 " let lline = search('^\s*\\\%(' . lpat . '\)', 'cn', firstNC + 1000)
1921 " let cline = search('^\s*\\\%(' . cpat . '\)', 'cn', firstNC + 1000)
1923 " let format = 'context'
1925 " if lline > 0 && (cline == 0 || cline > lline)
1926 " let format = 'tex'
1929 call setpos('.', save_cursor)
1930 endif " firstline =~ '^%&\s*\a\+'
1932 " Translation from formats to file types. TODO: add AMSTeX, RevTex, others?
1933 if format == 'plain'
1935 elseif format == 'context'
1937 else " probably LaTeX
1944 au BufNewFile,BufRead tex/context/*/*.tex,*.mkii,*.mkiv setf context
1947 au BufNewFile,BufRead *.texinfo,*.texi,*.txi setf texinfo
1950 au BufNewFile,BufRead texmf.cnf setf texmf
1953 au BufNewFile,BufRead .tidyrc,tidyrc setf tidy
1956 au BufNewFile,BufRead *.tf,.tfrc,tfrc setf tf
1958 " TPP - Text Presentation Program
1959 au BufNewFile,BufReadPost *.tpp setf tpp
1962 au BufNewFile,BufRead trustees.conf setf trustees
1965 au BufNewFile,BufReadPost *.tssgm setf tssgm
1968 au BufNewFile,BufReadPost *.tssop setf tssop
1970 " TSS - Command Line (temporary)
1971 au BufNewFile,BufReadPost *.tsscl setf tsscl
1973 " Motif UIT/UIL files
1974 au BufNewFile,BufRead *.uit,*.uil setf uil
1977 au BufNewFile,BufRead /etc/udev/udev.conf setf udevconf
1980 au BufNewFile,BufRead /etc/udev/rules.d/*.rules setf udevrules
1983 au BufNewFile,BufRead /etc/udev/permissions.d/*.permissions setf udevperm
1985 " Udev symlinks config
1986 au BufNewFile,BufRead /etc/udev/cdsymlinks.conf setf sh
1989 au BufNewFile,BufRead *.uc setf uc
1992 au BufNewFile,BufRead /etc/updatedb.conf setf updatedb
1995 au BufNewFile,BufRead *.vr,*.vri,*.vrh setf vera
1998 au BufNewFile,BufRead *.v setf verilog
2001 au BufNewFile,BufRead *.va,*.vams setf verilogams
2004 au BufNewFile,BufRead *.hdl,*.vhd,*.vhdl,*.vbe,*.vst setf vhdl
2005 au BufNewFile,BufRead *.vhdl_[0-9]* call s:StarSetf('vhdl')
2008 au BufNewFile,BufRead *.vim,*.vba,.exrc,_exrc setf vim
2011 au BufNewFile,BufRead .viminfo,_viminfo setf viminfo
2013 " Virata Config Script File
2014 au BufRead,BufNewFile *.hw,*.module,*.pkg setf virata
2016 " Visual Basic (also uses *.bas) or FORM
2017 au BufNewFile,BufRead *.frm call s:FTVB("form")
2019 " SaxBasic is close to Visual Basic
2020 au BufNewFile,BufRead *.sba setf vb
2023 au BufNewFile,BufRead vgrindefs setf vgrindefs
2026 au BufNewFile,BufRead *.wrl setf vrml
2029 au BufNewFile,BufRead *.wm setf webmacro
2032 au BufNewFile,BufRead .wgetrc,wgetrc setf wget
2034 " Website MetaLanguage
2035 au BufNewFile,BufRead *.wml setf wml
2038 au BufNewFile,BufRead *.wbt setf winbatch
2041 au BufNewFile,BufRead *.wsml setf wsml
2044 au BufNewFile,BufRead wvdial.conf,.wvdialrc setf wvdial
2047 au BufNewFile,BufRead .cvsrc setf cvsrc
2050 au BufNewFile,BufRead cvs\d\+ setf cvs
2052 " WEB (*.web is also used for Winbatch: Guess, based on expecting "%" comment
2053 " lines in a WEB file).
2054 au BufNewFile,BufRead *.web
2055 \ if getline(1)[0].getline(2)[0].getline(3)[0].getline(4)[0].getline(5)[0] =~ "%" |
2061 " Windows Scripting Host and Windows Script Component
2062 au BufNewFile,BufRead *.ws[fc] setf wsh
2065 au BufNewFile,BufRead *.xhtml,*.xht setf xhtml
2067 " X Pixmap (dynamically sets colors, use BufEnter to make it work better)
2069 \ if getline(1) =~ "XPM2" |
2074 au BufEnter *.xpm2 setf xpm2
2077 au BufNewFile,BufRead XF86Config
2078 \ if getline(1) =~ '\<XConfigurator\>' |
2079 \ let b:xf86c_xfree86_version = 3 |
2084 au BufNewFile,BufRead xorg.conf,xorg.conf-4 let b:xf86c_xfree86_version = 4 | setf xf86conf
2087 au BufNewFile,BufRead /etc/xinetd.conf setf xinetd
2089 " XS Perl extension interface language
2090 au BufNewFile,BufRead *.xs setf xs
2093 au BufNewFile,BufRead .Xdefaults,.Xpdefaults,.Xresources,xdm-config,*.ad setf xdefaults
2096 au BufNewFile,BufRead *.msc,*.msf setf xmath
2097 au BufNewFile,BufRead *.ms
2098 \ if !s:FTnroff() | setf xmath | endif
2100 " XML specific variants: docbk and xbl
2101 au BufNewFile,BufRead *.xml call s:FTxml()
2105 while n < 100 && n < line("$")
2106 let line = getline(n)
2107 if line =~ '<!DOCTYPE.*DocBook'
2108 let b:docbk_type = "xml"
2112 if line =~ 'xmlns:xbl="http://www.mozilla.org/xbl"'
2121 " XMI (holding UML models) is also XML
2122 au BufNewFile,BufRead *.xmi setf xml
2124 " CSPROJ files are Visual Studio.NET's XML-based project config files
2125 au BufNewFile,BufRead *.csproj,*.csproj.user setf xml
2127 " Qt Linguist translation source and Qt User Interface Files are XML
2128 au BufNewFile,BufRead *.ts,*.ui setf xml
2130 " TPM's are RDF-based descriptions of TeX packages (Nikolai Weibull)
2131 au BufNewFile,BufRead *.tpm setf xml
2134 au BufNewFile,BufRead /etc/xdg/menus/*.menu setf xml
2136 " ATI graphics driver configuration
2137 au BufNewFile,BufRead fglrxrc setf xml
2139 " XLIFF (XML Localisation Interchange File Format) is also XML
2140 au BufNewFile,BufRead *.xlf setf xml
2141 au BufNewFile,BufRead *.xliff setf xml
2143 " X11 xmodmap (also see below)
2144 au BufNewFile,BufRead *Xmodmap setf xmodmap
2147 au BufNewFile,BufRead *.xq,*.xql,*.xqm,*.xquery,*.xqy setf xquery
2150 au BufNewFile,BufRead *.xsd setf xsd
2153 au BufNewFile,BufRead *.xsl,*.xslt setf xslt
2156 au BufNewFile,BufRead *.yy setf yacc
2159 au BufNewFile,BufRead *.y call s:FTy()
2163 while n < 100 && n < line("$")
2164 let line = getline(n)
2169 if getline(n) =~ '^\s*\(#\|class\>\)' && getline(n) !~ '^\s*#\s*include'
2180 au BufNewFile,BufRead *.yaml,*.yml setf yaml
2183 " dtml (zope dynamic template markup language), pt (zope page template),
2184 " cpt (zope form controller page template)
2185 au BufNewFile,BufRead *.dtml,*.pt,*.cpt call s:FThtml()
2186 " zsql (zope sql method)
2187 au BufNewFile,BufRead *.zsql call s:SQL()
2189 " Z80 assembler asz80
2190 au BufNewFile,BufRead *.z8a setf z8a
2195 " Source the user-specified filetype file, for backwards compatibility with
2197 if exists("myfiletypefile") && filereadable(expand(myfiletypefile))
2198 execute "source " . myfiletypefile
2202 " Check for "*" after loading myfiletypefile, so that scripts.vim is only used
2203 " when there are no matching file name extensions.
2204 " Don't do this for compressed files.
2205 augroup filetypedetect
2206 au BufNewFile,BufRead *
2207 \ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
2208 \ | runtime! scripts.vim | endif
2209 au StdinReadPost * if !did_filetype() | runtime! scripts.vim | endif
2212 " Extra checks for when no filetype has been detected now. Mostly used for
2213 " patterns that end in "*". E.g., "zsh*" matches "zsh.vim", but that's a Vim
2215 " Most of these should call s:StarSetf() to avoid names ending in .gz and the
2218 " Asterisk config file
2219 au BufNewFile,BufRead *asterisk/*.conf* call s:StarSetf('asterisk')
2220 au BufNewFile,BufRead *asterisk*/*voicemail.conf* call s:StarSetf('asteriskvm')
2222 " Bazaar version control
2223 au BufNewFile,BufRead bzr_log.* setf bzr
2226 au BufNewFile,BufRead */named/db.*,*/bind/db.* call s:StarSetf('bindzone')
2229 au BufNewFile,BufRead [cC]hange[lL]og*
2230 \ if getline(1) =~ '; urgency='
2231 \| call s:StarSetf('debchangelog')
2233 \| call s:StarSetf('changelog')
2237 au BufNewFile,BufRead crontab,crontab.* call s:StarSetf('crontab')
2239 " Debian Sources.list
2240 au BufNewFile,BufRead /etc/apt/sources.list.d/* call s:StarSetf('debsources')
2243 au BufNewFile,BufRead drac.* call s:StarSetf('dracula')
2246 au BufNewFile,BufRead */.fvwm/* call s:StarSetf('fvwm')
2247 au BufNewFile,BufRead *fvwmrc*,*fvwm95*.hook
2248 \ let b:fvwm_version = 1 | call s:StarSetf('fvwm')
2249 au BufNewFile,BufRead *fvwm2rc*
2250 \ if expand("<afile>:e") == "m4"
2251 \| call s:StarSetf('fvwm2m4')
2253 \| let b:fvwm_version = 2 | call s:StarSetf('fvwm')
2257 au BufNewFile,BufRead .gtkrc*,gtkrc* call s:StarSetf('gtkrc')
2260 au BufNewFile,BufRead Prl*.*,JAM*.* call s:StarSetf('jam')
2263 au! BufNewFile,BufRead *jarg*
2264 \ if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'THIS IS THE JARGON FILE'
2265 \| call s:StarSetf('jargon')
2269 au BufNewFile,BufRead Kconfig.* call s:StarSetf('kconfig')
2272 au BufNewFile,BufRead [mM]akefile* call s:StarSetf('make')
2275 au BufNewFile,BufRead [rR]akefile* call s:StarSetf('ruby')
2277 " Mail (also matches muttrc.vim, so this is below the other checks)
2278 au BufNewFile,BufRead mutt[[:alnum:]._-]\{6\} setf mail
2281 au BufNewFile,BufRead /etc/modprobe.* call s:StarSetf('modconf')
2284 au BufNewFile,BufRead .mutt{ng,}rc*,*/.mutt{ng,}/mutt{ng,}rc* call s:StarSetf('muttrc')
2285 au BufNewFile,BufRead mutt{ng,}rc*,Mutt{ng,}rc* call s:StarSetf('muttrc')
2288 au BufNewFile,BufRead tmac.* call s:StarSetf('nroff')
2291 au BufNewFile,BufRead /etc/pam.d/* call s:StarSetf('pamconf')
2293 " Printcap and Termcap
2294 au BufNewFile,BufRead *printcap*
2295 \ if !did_filetype()
2296 \| let b:ptcap_type = "print" | call s:StarSetf('ptcap')
2298 au BufNewFile,BufRead *termcap*
2299 \ if !did_filetype()
2300 \| let b:ptcap_type = "term" | call s:StarSetf('ptcap')
2304 au BufNewFile,BufRead *vimrc* call s:StarSetf('vim')
2306 " Subversion commit file
2307 au BufNewFile,BufRead svn-commit*.tmp setf svn
2310 au BufNewFile,BufRead Xresources*,*/app-defaults/*,*/Xresources/* call s:StarSetf('xdefaults')
2313 au BufNewFile,BufRead XF86Config-4*
2314 \ let b:xf86c_xfree86_version = 4 | call s:StarSetf('xf86conf')
2315 au BufNewFile,BufRead XF86Config*
2316 \ if getline(1) =~ '\<XConfigurator\>'
2317 \| let b:xf86c_xfree86_version = 3
2319 \|call s:StarSetf('xf86conf')
2322 au BufNewFile,BufRead *xmodmap* call s:StarSetf('xmodmap')
2325 au BufNewFile,BufRead /etc/xinetd.d/* call s:StarSetf('xinetd')
2328 au BufNewFile,BufRead zsh*,zlog* call s:StarSetf('zsh')
2331 " Generic configuration file (check this last, it's just guessing!)
2332 au BufNewFile,BufRead,StdinReadPost *
2333 \ if !did_filetype() && expand("<amatch>") !~ g:ft_ignore_pat
2334 \ && (getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#'
2335 \ || getline(4) =~ '^#' || getline(5) =~ '^#') |
2339 " Use the plugin-filetype checks last, they may overrule any of the previously
2340 " detected filetypes.
2341 runtime! ftdetect/*.vim
2346 " If the GUI is already running, may still need to install the Syntax menu.
2347 " Don't do it when the 'M' flag is included in 'guioptions'.
2348 if has("menu") && has("gui_running")
2349 \ && !exists("did_install_syntax_menu") && &guioptions !~# "M"
2350 source <sfile>:p:h/menu.vim
2353 " Function called for testing all functions defined here. These are
2354 " script-local, thus need to be executed here.
2355 " Returns a string with error messages (hopefully empty).
2356 func! TestFiletypeFuncs(testlist)
2362 let output = output . "\n" . f . ": " . v:exception
2368 " Restore 'cpoptions'
2369 let &cpo = s:cpo_save