" Vim support file to detect file types"" Maintainer: Bram Moolenaar <Bram@vim.org>" Last Change: 2007 May 10 " Listen very carefully, I will say this only onceif exists("did_load_filetypes") finishendiflet did_load_filetypes = 1 " Line continuation is used here, remove 'C' from 'cpoptions'let s:cpo_save = &cposet cpo&vim augroup filetypedetect " Ignored extensionsau BufNewFile,BufRead ?\+.orig,?\+.bak,?\+.old,?\+.new,?\+.rpmsave,?\+.rpmnew \ exe "doau filetypedetect BufRead " . expand("<afile>:r")au BufNewFile,BufRead *~ \ let s:name = expand("<afile>") | \ let s:short = substitute(s:name, '\~$', '', '') | \ if s:name != s:short && s:short != "" | \ exe "doau filetypedetect BufRead " . s:short | \ endif | \ unlet s:name | \ unlet s:shortau BufNewFile,BufRead ?\+.in \ if expand("<afile>:t") != "configure.in" | \ exe "doau filetypedetect BufRead " . expand("<afile>:r") | \ endif " Pattern used to match file names which should not be inspected." Currently finds compressed files.if !exists("g:ft_ignore_pat") let g:ft_ignore_pat = '\.\(Z\|gz\|bz2\|zip\|tgz\)$'endif " Function used for patterns that end in a star: don't set the filetype if the" file name matches ft_ignore_pat.func! s:StarSetf(ft) if expand("<amatch>") !~ g:ft_ignore_pat exe 'setf ' . a:ft endifendfunc " Abaqus or Trasysau BufNewFile,BufRead *.inp call s:Check_inp() func! s:Check_inp() if getline(1) =~ '^\*' setf abaqus else let n = 1 if line("$") > 500 let nmax = 500 else let nmax = line("$") endif while n <= nmax if getline(n) =~? "^header surface data" setf trasys break endif let n = n + 1 endwhile endifendfunc " A-A-P recipeau BufNewFile,BufRead *.aap setf aap " A2ps printing utilityau BufNewFile,BufRead etc/a2ps.cfg,etc/a2ps/*.cfg,a2psrc,.a2psrc setf a2ps " ABAB/4au BufNewFile,BufRead *.abap setf abap " ABC music notationau BufNewFile,BufRead *.abc setf abc " ABELau BufNewFile,BufRead *.abl setf abel " AceDBau BufNewFile,BufRead *.wrm setf acedb " Ada (83, 9X, 95)au BufNewFile,BufRead *.adb,*.ads,*.ada setf adaif has("vms") au BufNewFile,BufRead *.gpr,*.ada_m,*.adc setf adaelse au BufNewFile,BufRead *.gpr setf adaendif " AHDLau BufNewFile,BufRead *.tdf setf ahdl " AMPLau BufNewFile,BufRead *.run setf ampl " Antau BufNewFile,BufRead build.xml setf ant " Apache style config fileau BufNewFile,BufRead proftpd.conf* call s:StarSetf('apachestyle') " Apache config fileau BufNewFile,BufRead .htaccess setf apacheau BufNewFile,BufRead httpd.conf*,srm.conf*,access.conf*,apache.conf*,apache2.conf*,/etc/apache2/*.conf* call s:StarSetf('apache') " XA65 MOS6510 cross assemblerau BufNewFile,BufRead *.a65 setf a65 " Applix ELFau BufNewFile,BufRead *.am \ if expand("<afile>") !~? 'Makefile.am\>' | setf elf | endif " ALSA configurationau BufNewFile,BufRead ~/.asoundrc,/usr/share/alsa/alsa.conf,/etc/asound.conf setf alsaconf " Arc Macro Languageau BufNewFile,BufRead *.aml setf aml " Arch Inventory fileau BufNewFile,BufRead .arch-inventory,=tagging-method setf arch " ART*Enterprise (formerly ART-IM)au BufNewFile,BufRead *.art setf art " ASN.1au BufNewFile,BufRead *.asn,*.asn1 setf asn " Active Server Pages (with Visual Basic Script)au BufNewFile,BufRead *.asa \ if exists("g:filetype_asa") | \ exe "setf " . g:filetype_asa | \ else | \ setf aspvbs | \ endif " Active Server Pages (with Perl or Visual Basic Script)au BufNewFile,BufRead *.asp \ if exists("g:filetype_asp") | \ exe "setf " . g:filetype_asp | \ elseif getline(1) . getline(2) . getline(3) =~? "perlscript" | \ setf aspperl | \ else | \ setf aspvbs | \ endif " Grub (must be before catch *.lst)au BufNewFile,BufRead /boot/grub/menu.lst,/boot/grub/grub.conf,/etc/grub.conf setf grub " Assembly (all kinds)" *.lst is not pure assembly, it has two extra columns (address, byte codes)au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst call s:FTasm() " This function checks for the kind of assembly that is wanted by the user, or" can be detected from the first five lines of the file.func! s:FTasm() " make sure b:asmsyntax exists if !exists("b:asmsyntax") let b:asmsyntax = "" endif if b:asmsyntax == "" call s:FTasmsyntax() endif " if b:asmsyntax still isn't set, default to asmsyntax or GNU if b:asmsyntax == "" if exists("g:asmsyntax") let b:asmsyntax = g:asmsyntax else let b:asmsyntax = "asm" endif endif exe "setf " . b:asmsyntaxendfunc func! s:FTasmsyntax() " see if file contains any asmsyntax=foo overrides. If so, change " b:asmsyntax appropriately let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4). \" ".getline(5)." " if head =~ '\sasmsyntax=\S\+\s' let b:asmsyntax = substitute(head, '.*\sasmsyntax=\(\S\+\)\s.*','\1', "") elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library')) let b:asmsyntax = "vmasm" endifendfunc " Macro (VAX)au BufNewFile,BufRead *.mar setf vmasm " Atlasau BufNewFile,BufRead *.atl,*.as setf atlas " Autoit v3au BufNewFile,BufRead *.au3 setf autoit " Autohotkeyau BufNewFile,BufRead *.ahk setf autohotkey " Automakeau BufNewFile,BufRead [mM]akefile.am,GNUmakefile.am setf automake " Autotest .at files are actually m4au BufNewFile,BufRead *.at setf m4 " Avenueau BufNewFile,BufRead *.ave setf ave " Awkau BufNewFile,BufRead *.awk setf awk " Bau BufNewFile,BufRead *.mch,*.ref,*.imp setf b " BASIC or Visual Basicau BufNewFile,BufRead *.bas call s:FTVB("basic") " Check if one of the first five lines contains "VB_Name". In that case it is" probably a Visual Basic file. Otherwise it's assumed to be "alt" filetype.func! s:FTVB(alt) if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)' setf vb else exe "setf " . a:alt endifendfunc " Visual Basic Script (close to Visual Basic)au BufNewFile,BufRead *.vbs,*.dsm,*.ctl setf vb " IBasic file (similar to QBasic)au BufNewFile,BufRead *.iba,*.ibi setf ibasic " FreeBasic file (similar to QBasic)au BufNewFile,BufRead *.fb,*.bi setf freebasic " Batch file for MSDOS.au BufNewFile,BufRead *.bat,*.sys setf dosbatch" *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd.au BufNewFile,BufRead *.cmd \ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif " Batch file for 4DOSau BufNewFile,BufRead *.btm call s:FTbtm()func! s:FTbtm() if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm setf dosbatch else setf btm endifendfunc " BC calculatorau BufNewFile,BufRead *.bc setf bc " BDF fontau BufNewFile,BufRead *.bdf setf bdf " BibTeX bibliography database fileau BufNewFile,BufRead *.bib setf bib " BibTeX Bibliography Styleau BufNewFile,BufRead *.bst setf bst " BIND configurationau BufNewFile,BufRead named.conf,rndc.conf setf named " BIND zoneau BufNewFile,BufRead named.root setf bindzoneau BufNewFile,BufRead *.db call s:BindzoneCheck('') func! s:BindzoneCheck(default) if getline(1).getline(2).getline(3).getline(4) =~ '^; <<>> DiG [0-9.]\+ <<>>\|BIND.*named\|$ORIGIN\|$TTL\|IN\s\+SOA' setf bindzone elseif a:default != '' exe 'setf ' . a:default endifendfunc " Blankau BufNewFile,BufRead *.bl setf blank " C or lpcau BufNewFile,BufRead *.c call s:FTlpc() func! s:FTlpc() if exists("g:lpc_syntax_for_c") let lnum = 1 while lnum <= 12 if getline(lnum) =~# '^\(//\|inherit\|private\|protected\|nosave\|string\|object\|mapping\|mixed\)' setf lpc return endif let lnum = lnum + 1 endwhile endif setf cendfunc " Calendarau BufNewFile,BufRead calendar setf calendarau BufNewFile,BufRead */.calendar/*, \*/share/calendar/*/calendar.*,*/share/calendar/calendar.* \ call s:StarSetf('calendar') " C#au BufNewFile,BufRead *.cs setf cs " Cdrdao TOCau BufNewFile,BufRead *.toc setf cdrtoc " Cfengineau BufNewFile,BufRead cfengine.conf setf cfengine " Comshare Dimension Definition Languageau BufNewFile,BufRead *.cdl setf cdl " Conary Recipeau BufNewFile,BufRead *.recipe setf conaryrecipe " Controllable Regex Mutilatorau BufNewFile,BufRead *.crm setf crm " Cyn++au BufNewFile,BufRead *.cyn setf cynpp " Cynlib" .cc and .cpp files can be C++ or Cynlib.au BufNewFile,BufRead *.cc \ if exists("cynlib_syntax_for_cc")|setf cynlib|else|setf cpp|endifau BufNewFile,BufRead *.cpp \ if exists("cynlib_syntax_for_cpp")|setf cynlib|else|setf cpp|endif " C++if has("fname_case") au BufNewFile,BufRead *.cxx,*.c++,*.C,*.H,*.hh,*.hxx,*.hpp,*.moc,*.tcc,*.inl setf cppelse au BufNewFile,BufRead *.cxx,*.c++,*.hh,*.hxx,*.hpp,*.moc,*.tcc,*.inl setf cppendif " .h files can be C, Ch or C++, set c_syntax_for_h if you want C," ch_syntax_for_h if you want Ch.au BufNewFile,BufRead *.h \ if exists("c_syntax_for_h") | setf c | \ elseif exists("ch_syntax_for_h") | setf ch | \ else | setf cpp | endif " Ch (CHscript)au BufNewFile,BufRead *.chf setf ch " TLH files are C++ headers generated by Visual C++'s #import from typelibsau BufNewFile,BufRead *.tlh setf cpp " Cascading Style Sheetsau BufNewFile,BufRead *.css setf css " Century Term Command Scripts (*.cmd too)au BufNewFile,BufRead *.con setf cterm " Changelogau BufNewFile,BufRead changelog.Debian,changelog.dch,NEWS.Debian,NEWS.dch \ setf debchangelog au BufNewFile,BufRead [cC]hange[lL]og \ if getline(1) =~ '; urgency=' \| setf debchangelog \| else \| setf changelog \| endif au BufNewFile,BufRead NEWS \ if getline(1) =~ '; urgency=' \| setf debchangelog \| endif " CHILLau BufNewFile,BufRead *..ch setf chill " Changes for WEB and CWEB or CHILLau BufNewFile,BufRead *.ch call s:FTchange() " This function checks if one of the first ten lines start with a '@'. In" that case it is probably a change file." If the first line starts with # or ! it's probably a ch file." If a line has "main", "include", "//" ir "/*" it's probably ch." Otherwise CHILL is assumed.func! s:FTchange() let lnum = 1 while lnum <= 10 if getline(lnum)[0] == '@' setf change return endif if lnum == 1 && (getline(1)[0] == '#' || getline(1)[0] == '!') setf ch return endif if getline(lnum) =~ "MODULE" setf chill return endif if getline(lnum) =~ 'main\s*(\|#\s*include\|//' setf ch return endif let lnum = lnum + 1 endwhile setf chillendfunc " ChordProau BufNewFile,BufRead *.chopro,*.crd,*.cho,*.crdpro,*.chordpro setf chordpro " Cleanau BufNewFile,BufRead *.dcl,*.icl setf clean " Cleverau BufNewFile,BufRead *.eni setf cl " Clever or dtdau BufNewFile,BufRead *.ent call s:FTent() func! s:FTent() " This function checks for valid cl syntax in the first five lines. " Look for either an opening comment, '#', or a block start, '{". " If not found, assume SGML. let lnum = 1 while lnum < 6 let line = getline(lnum) if line =~ '^\s*[#{]' setf cl return elseif line !~ '^\s*$' " Not a blank line, not a comment, and not a block start, " so doesn't look like valid cl code. break endif let lnum = lnum + 1 endw setf dtdendfunc " Clipper (or FoxPro; could also be eviews)au BufNewFile,BufRead *.prg \ if exists("g:filetype_prg") | \ exe "setf " . g:filetype_prg | \ else | \ setf clipper | \ endif " Cmakeau BufNewFile,BufRead CMakeLists.txt,*.cmake,*.cmake.in setf cmake " Cmusrcau BufNewFile,BufRead ~/.cmus/{autosave,rc,command-history,*.theme} setf cmusrcau BufNewFile,BufRead */cmus/{rc,*.theme} setf cmusrc " Cobolau BufNewFile,BufRead *.cbl,*.cob,*.lib setf cobol" cobol or zope form controller python script? (heuristic)au BufNewFile,BufRead *.cpy \ if getline(1) =~ '^##' | \ setf python | \ else | \ setf cobol | \ endif " Cold Fusionau BufNewFile,BufRead *.cfm,*.cfi,*.cfc setf cf " Configure scriptsau BufNewFile,BufRead configure.in,configure.ac setf config " WildPackets EtherPeek Decoderau BufNewFile,BufRead *.dcd setf dcd " Enlightenment configuration filesau BufNewFile,BufRead *enlightenment/*.cfg setf c " Etermau BufNewFile,BufRead *Eterm/*.cfg setf eterm " Lynx config filesau BufNewFile,BufRead lynx.cfg setf lynx " Quakeau BufNewFile,BufRead *baseq[2-3]/*.cfg,*id1/*.cfg setf quakeau BufNewFile,BufRead *quake[1-3]/*.cfg setf quake " Quake Cau BufNewFile,BufRead *.qc setf c Lines 1–500 of 2293. Load more
" Vim support file to detect file types " " Maintainer: Bram Moolenaar <Bram@vim.org> " Last Change: 2007 May 10 " Listen very carefully, I will say this only once if exists("did_load_filetypes") finish endif let did_load_filetypes = 1 " Line continuation is used here, remove 'C' from 'cpoptions' let s:cpo_save = &cpo set cpo&vim augroup filetypedetect " Ignored extensions au BufNewFile,BufRead ?\+.orig,?\+.bak,?\+.old,?\+.new,?\+.rpmsave,?\+.rpmnew \ exe "doau filetypedetect BufRead " . expand("<afile>:r") au BufNewFile,BufRead *~ \ let s:name = expand("<afile>") | \ let s:short = substitute(s:name, '\~$', '', '') | \ if s:name != s:short && s:short != "" | \ exe "doau filetypedetect BufRead " . s:short | \ endif | \ unlet s:name | \ unlet s:short au BufNewFile,BufRead ?\+.in \ if expand("<afile>:t") != "configure.in" | \ exe "doau filetypedetect BufRead " . expand("<afile>:r") | \ endif " Pattern used to match file names which should not be inspected. " Currently finds compressed files. if !exists("g:ft_ignore_pat") let g:ft_ignore_pat = '\.\(Z\|gz\|bz2\|zip\|tgz\)$' endif " Function used for patterns that end in a star: don't set the filetype if the " file name matches ft_ignore_pat. func! s:StarSetf(ft) if expand("<amatch>") !~ g:ft_ignore_pat exe 'setf ' . a:ft endif endfunc " Abaqus or Trasys au BufNewFile,BufRead *.inp call s:Check_inp() func! s:Check_inp() if getline(1) =~ '^\*' setf abaqus else let n = 1 if line("$") > 500 let nmax = 500 else let nmax = line("$") endif while n <= nmax if getline(n) =~? "^header surface data" setf trasys break endif let n = n + 1 endwhile endif endfunc " A-A-P recipe au BufNewFile,BufRead *.aap setf aap " A2ps printing utility au BufNewFile,BufRead etc/a2ps.cfg,etc/a2ps/*.cfg,a2psrc,.a2psrc setf a2ps " ABAB/4 au BufNewFile,BufRead *.abap setf abap " ABC music notation au BufNewFile,BufRead *.abc setf abc " ABEL au BufNewFile,BufRead *.abl setf abel " AceDB au BufNewFile,BufRead *.wrm setf acedb " Ada (83, 9X, 95) au BufNewFile,BufRead *.adb,*.ads,*.ada setf ada if has("vms") au BufNewFile,BufRead *.gpr,*.ada_m,*.adc setf ada else au BufNewFile,BufRead *.gpr setf ada endif " AHDL au BufNewFile,BufRead *.tdf setf ahdl " AMPL au BufNewFile,BufRead *.run setf ampl " Ant au BufNewFile,BufRead build.xml setf ant " Apache style config file au BufNewFile,BufRead proftpd.conf* call s:StarSetf('apachestyle') " Apache config file au BufNewFile,BufRead .htaccess setf apache au BufNewFile,BufRead httpd.conf*,srm.conf*,access.conf*,apache.conf*,apache2.conf*,/etc/apache2/*.conf* call s:StarSetf('apache') " XA65 MOS6510 cross assembler au BufNewFile,BufRead *.a65 setf a65 " Applix ELF au BufNewFile,BufRead *.am \ if expand("<afile>") !~? 'Makefile.am\>' | setf elf | endif " ALSA configuration au BufNewFile,BufRead ~/.asoundrc,/usr/share/alsa/alsa.conf,/etc/asound.conf setf alsaconf " Arc Macro Language au BufNewFile,BufRead *.aml setf aml " Arch Inventory file au BufNewFile,BufRead .arch-inventory,=tagging-method setf arch " ART*Enterprise (formerly ART-IM) au BufNewFile,BufRead *.art setf art " ASN.1 au BufNewFile,BufRead *.asn,*.asn1 setf asn " Active Server Pages (with Visual Basic Script) au BufNewFile,BufRead *.asa \ if exists("g:filetype_asa") | \ exe "setf " . g:filetype_asa | \ else | \ setf aspvbs | \ endif " Active Server Pages (with Perl or Visual Basic Script) au BufNewFile,BufRead *.asp \ if exists("g:filetype_asp") | \ exe "setf " . g:filetype_asp | \ elseif getline(1) . getline(2) . getline(3) =~? "perlscript" | \ setf aspperl | \ else | \ setf aspvbs | \ endif " Grub (must be before catch *.lst) au BufNewFile,BufRead /boot/grub/menu.lst,/boot/grub/grub.conf,/etc/grub.conf setf grub " Assembly (all kinds) " *.lst is not pure assembly, it has two extra columns (address, byte codes) au BufNewFile,BufRead *.asm,*.[sS],*.[aA],*.mac,*.lst call s:FTasm() " This function checks for the kind of assembly that is wanted by the user, or " can be detected from the first five lines of the file. func! s:FTasm() " make sure b:asmsyntax exists if !exists("b:asmsyntax") let b:asmsyntax = "" endif if b:asmsyntax == "" call s:FTasmsyntax() endif " if b:asmsyntax still isn't set, default to asmsyntax or GNU if b:asmsyntax == "" if exists("g:asmsyntax") let b:asmsyntax = g:asmsyntax else let b:asmsyntax = "asm" endif endif exe "setf " . b:asmsyntax endfunc func! s:FTasmsyntax() " see if file contains any asmsyntax=foo overrides. If so, change " b:asmsyntax appropriately let head = " ".getline(1)." ".getline(2)." ".getline(3)." ".getline(4). \" ".getline(5)." " if head =~ '\sasmsyntax=\S\+\s' let b:asmsyntax = substitute(head, '.*\sasmsyntax=\(\S\+\)\s.*','\1', "") elseif ((head =~? '\.title') || (head =~? '\.ident') || (head =~? '\.macro') || (head =~? '\.subtitle') || (head =~? '\.library')) let b:asmsyntax = "vmasm" endif endfunc " Macro (VAX) au BufNewFile,BufRead *.mar setf vmasm " Atlas au BufNewFile,BufRead *.atl,*.as setf atlas " Autoit v3 au BufNewFile,BufRead *.au3 setf autoit " Autohotkey au BufNewFile,BufRead *.ahk setf autohotkey " Automake au BufNewFile,BufRead [mM]akefile.am,GNUmakefile.am setf automake " Autotest .at files are actually m4 au BufNewFile,BufRead *.at setf m4 " Avenue au BufNewFile,BufRead *.ave setf ave " Awk au BufNewFile,BufRead *.awk setf awk " B au BufNewFile,BufRead *.mch,*.ref,*.imp setf b " BASIC or Visual Basic au BufNewFile,BufRead *.bas call s:FTVB("basic") " Check if one of the first five lines contains "VB_Name". In that case it is " probably a Visual Basic file. Otherwise it's assumed to be "alt" filetype. func! s:FTVB(alt) if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)' setf vb else exe "setf " . a:alt endif endfunc " Visual Basic Script (close to Visual Basic) au BufNewFile,BufRead *.vbs,*.dsm,*.ctl setf vb " IBasic file (similar to QBasic) au BufNewFile,BufRead *.iba,*.ibi setf ibasic " FreeBasic file (similar to QBasic) au BufNewFile,BufRead *.fb,*.bi setf freebasic " Batch file for MSDOS. au BufNewFile,BufRead *.bat,*.sys setf dosbatch " *.cmd is close to a Batch file, but on OS/2 Rexx files also use *.cmd. au BufNewFile,BufRead *.cmd \ if getline(1) =~ '^/\*' | setf rexx | else | setf dosbatch | endif " Batch file for 4DOS au BufNewFile,BufRead *.btm call s:FTbtm() func! s:FTbtm() if exists("g:dosbatch_syntax_for_btm") && g:dosbatch_syntax_for_btm setf dosbatch else setf btm endif endfunc " BC calculator au BufNewFile,BufRead *.bc setf bc " BDF font au BufNewFile,BufRead *.bdf setf bdf " BibTeX bibliography database file au BufNewFile,BufRead *.bib setf bib " BibTeX Bibliography Style au BufNewFile,BufRead *.bst setf bst " BIND configuration au BufNewFile,BufRead named.conf,rndc.conf setf named " BIND zone au BufNewFile,BufRead named.root setf bindzone au BufNewFile,BufRead *.db call s:BindzoneCheck('') func! s:BindzoneCheck(default) if getline(1).getline(2).getline(3).getline(4) =~ '^; <<>> DiG [0-9.]\+ <<>>\|BIND.*named\|$ORIGIN\|$TTL\|IN\s\+SOA' setf bindzone elseif a:default != '' exe 'setf ' . a:default endif endfunc " Blank au BufNewFile,BufRead *.bl setf blank " C or lpc au BufNewFile,BufRead *.c call s:FTlpc() func! s:FTlpc() if exists("g:lpc_syntax_for_c") let lnum = 1 while lnum <= 12 if getline(lnum) =~# '^\(//\|inherit\|private\|protected\|nosave\|string\|object\|mapping\|mixed\)' setf lpc return endif let lnum = lnum + 1 endwhile endif setf c endfunc " Calendar au BufNewFile,BufRead calendar setf calendar au BufNewFile,BufRead */.calendar/*, \*/share/calendar/*/calendar.*,*/share/calendar/calendar.* \ call s:StarSetf('calendar') " C# au BufNewFile,BufRead *.cs setf cs " Cdrdao TOC au BufNewFile,BufRead *.toc setf cdrtoc " Cfengine au BufNewFile,BufRead cfengine.conf setf cfengine " Comshare Dimension Definition Language au BufNewFile,BufRead *.cdl setf cdl " Conary Recipe au BufNewFile,BufRead *.recipe setf conaryrecipe " Controllable Regex Mutilator au BufNewFile,BufRead *.crm setf crm " Cyn++ au BufNewFile,BufRead *.cyn setf cynpp " Cynlib " .cc and .cpp files can be C++ or Cynlib. au BufNewFile,BufRead *.cc \ if exists("cynlib_syntax_for_cc")|setf cynlib|else|setf cpp|endif au BufNewFile,BufRead *.cpp \ if exists("cynlib_syntax_for_cpp")|setf cynlib|else|setf cpp|endif " C++ if has("fname_case") au BufNewFile,BufRead *.cxx,*.c++,*.C,*.H,*.hh,*.hxx,*.hpp,*.moc,*.tcc,*.inl setf cpp else au BufNewFile,BufRead *.cxx,*.c++,*.hh,*.hxx,*.hpp,*.moc,*.tcc,*.inl setf cpp endif " .h files can be C, Ch or C++, set c_syntax_for_h if you want C, " ch_syntax_for_h if you want Ch. au BufNewFile,BufRead *.h \ if exists("c_syntax_for_h") | setf c | \ elseif exists("ch_syntax_for_h") | setf ch | \ else | setf cpp | endif " Ch (CHscript) au BufNewFile,BufRead *.chf setf ch " TLH files are C++ headers generated by Visual C++'s #import from typelibs au BufNewFile,BufRead *.tlh setf cpp " Cascading Style Sheets au BufNewFile,BufRead *.css setf css " Century Term Command Scripts (*.cmd too) au BufNewFile,BufRead *.con setf cterm " Changelog au BufNewFile,BufRead changelog.Debian,changelog.dch,NEWS.Debian,NEWS.dch \ setf debchangelog au BufNewFile,BufRead [cC]hange[lL]og \ if getline(1) =~ '; urgency=' \| setf debchangelog \| else \| setf changelog \| endif au BufNewFile,BufRead NEWS \ if getline(1) =~ '; urgency=' \| setf debchangelog \| endif " CHILL au BufNewFile,BufRead *..ch setf chill " Changes for WEB and CWEB or CHILL au BufNewFile,BufRead *.ch call s:FTchange() " This function checks if one of the first ten lines start with a '@'. In " that case it is probably a change file. " If the first line starts with # or ! it's probably a ch file. " If a line has "main", "include", "//" ir "/*" it's probably ch. " Otherwise CHILL is assumed. func! s:FTchange() let lnum = 1 while lnum <= 10 if getline(lnum)[0] == '@' setf change return endif if lnum == 1 && (getline(1)[0] == '#' || getline(1)[0] == '!') setf ch return endif if getline(lnum) =~ "MODULE" setf chill return endif if getline(lnum) =~ 'main\s*(\|#\s*include\|//' setf ch return endif let lnum = lnum + 1 endwhile setf chill endfunc " ChordPro au BufNewFile,BufRead *.chopro,*.crd,*.cho,*.crdpro,*.chordpro setf chordpro " Clean au BufNewFile,BufRead *.dcl,*.icl setf clean " Clever au BufNewFile,BufRead *.eni setf cl " Clever or dtd au BufNewFile,BufRead *.ent call s:FTent() func! s:FTent() " This function checks for valid cl syntax in the first five lines. " Look for either an opening comment, '#', or a block start, '{". " If not found, assume SGML. let lnum = 1 while lnum < 6 let line = getline(lnum) if line =~ '^\s*[#{]' setf cl return elseif line !~ '^\s*$' " Not a blank line, not a comment, and not a block start, " so doesn't look like valid cl code. break endif let lnum = lnum + 1 endw setf dtd endfunc " Clipper (or FoxPro; could also be eviews) au BufNewFile,BufRead *.prg \ if exists("g:filetype_prg") | \ exe "setf " . g:filetype_prg | \ else | \ setf clipper | \ endif " Cmake au BufNewFile,BufRead CMakeLists.txt,*.cmake,*.cmake.in setf cmake " Cmusrc au BufNewFile,BufRead ~/.cmus/{autosave,rc,command-history,*.theme} setf cmusrc au BufNewFile,BufRead */cmus/{rc,*.theme} setf cmusrc " Cobol au BufNewFile,BufRead *.cbl,*.cob,*.lib setf cobol " cobol or zope form controller python script? (heuristic) au BufNewFile,BufRead *.cpy \ if getline(1) =~ '^##' | \ setf python | \ else | \ setf cobol | \ endif " Cold Fusion au BufNewFile,BufRead *.cfm,*.cfi,*.cfc setf cf " Configure scripts au BufNewFile,BufRead configure.in,configure.ac setf config " WildPackets EtherPeek Decoder au BufNewFile,BufRead *.dcd setf dcd " Enlightenment configuration files au BufNewFile,BufRead *enlightenment/*.cfg setf c " Eterm au BufNewFile,BufRead *Eterm/*.cfg setf eterm " Lynx config files au BufNewFile,BufRead lynx.cfg setf lynx " Quake au BufNewFile,BufRead *baseq[2-3]/*.cfg,*id1/*.cfg setf quake au BufNewFile,BufRead *quake[1-3]/*.cfg setf quake " Quake C au BufNewFile,BufRead *.qc setf c