📄 scripts.vim
字号:
" Vim support file to detect file types in scripts"" Maintainer: Bram Moolenaar <Bram@vim.org>" Last change: 2001 May 03" This file is called by an autocommand for every file that has just been" loaded into a buffer. It checks if the type of file can be recognized by" the file contents. The autocommand is in $VIMRUNTIME/filetype.vim." Load the user defined scripts file first" Only do this when the FileType autocommand has not been triggered yetif !did_filetype() && exists("myscriptsfile") && file_readable(expand(myscriptsfile)) execute "source " . myscriptsfileendif" Only do this when the FileType autocommand has not been triggered yetif !did_filetype()" Line continuation is used here, remove 'C' from 'cpoptions'let scr_cpo_save = &cposet cpo-=C" Bourne-like shell scripts: sh ksh bash bash2if getline(1) =~ '^#!.*[/\\]\(bash\|bash2\|ksh\|sh\)\>' call SetFileTypeSH(getline(1)) " defined in filetype.vim" csh and tcsh scriptselseif getline(1) =~ '^#!.*[/\\]t\=csh\>' set ft=csh" Z shell scriptselseif getline(1) =~ '^#!.*[/\\]zsh\>' \ || getline(1) =~ '^#compdef\>' \ || getline(1) =~ '^#autoload\>' set ft=zsh" TCL scriptselseif getline(1) =~ '^#!.*[/\\]\(tclsh\|wish\|expectk\|itclsh\|itkwish\)\>' set ft=tcl" ELM Mail fileselseif getline(1) =~ '^From [a-zA-Z][a-zA-Z_0-9\.=-]*\(@[^ ]*\)\= .*[12][09]\d\d$' set ft=mail" Expect scriptselseif getline(1) =~ '^#!.*[/\\]expect\>' set ft=expect" Gnuplot scriptselseif getline(1) =~ '^#!.*[/\\]gnuplot\>' set ft=gnuplot" Makefileselseif getline(1) =~ '^#!.*[/\\][^/\\]*make\>' set ft=make" Perlelseif getline(1) =~ '^#!.*[/\\][^/\\]*perl[^/\\]*\>' set ft=perl" Pythonelseif getline(1) =~ '^#!.*[/\\][^/\\]*python[^/\\]*\>' set ft=python" Rubyelseif getline(1) =~ '^#!.*[/\\][^/\\]*ruby[^/\\]*\>' set ft=ruby" BC calculatorelseif getline(1) =~ '^#!.*[/\\]bc\>' set ft=bc" sedelseif getline(1) =~ '^#!.*sed\>' set ft=sed" Vim scripts (must have '" vim' as the first line to trigger this)elseif getline(1) =~ '^" *[vV]im$' set ft=vim" Diff file:" - "diff" in first line (context diff)" - "Only in " in first line" - "--- " in first line and "+++ " in second line (unified diff)." - "*** " in first line and "--- " in second line (context diff)." - "# It was generated by makepatch " in the second line (makepatch diff)." - "Index: <filename>" in the first line (CVS file)elseif getline(1) =~ '^diff\>' || getline(1) =~ '^Only in ' \ || (getline(1) =~ '^--- ' && getline(2) =~ '^+++ ') \ || (getline(1) =~ '^\*\*\* ' && getline(2) =~ '^--- ') \ || getline(1) =~ '^\d\+\(,\d\+\)\=[cda]\d\+\>' \ || getline(2) =~ '^# It was generated by makepatch ' \ || getline(1) =~ '^Index:\s\+\f\+$' \ || getline(1) =~ '^==== //\f\+#\d\+' set ft=diff" PostScript Files (must have %!PS as the first line, like a2ps output)elseif getline(1) =~ '^%![ \t]*PS' set ft=postscr" Awk scriptselseif getline(1) =~ '^#!.*awk\>' set ft=awk" M4 scripts: Guess there is a line that starts with "dnl".elseif getline(1) =~ '^\s*dnl\>' \ || getline(2) =~ '^\s*dnl\>' \ || getline(3) =~ '^\s*dnl\>' \ || getline(4) =~ '^\s*dnl\>' \ || getline(5) =~ '^\s*dnl\>' set ft=m4" AmigaDos scriptselseif $TERM == "amiga" \ && (getline(1) =~ "^;" || getline(1) =~ '^\.[bB][rR][aA]') set ft=amiga" SiCAD scripts (must have procn or procd as the first line to trigger this)elseif getline(1) =~ '^ *[pP][rR][oO][cC][nNdD] *$' set ft=sicad" Purify log files start with "**** Purify"elseif getline(1) =~ '^\*\*\*\* Purify' set ft=purifylog" XMLelseif getline(1) =~ '<?\s*xml.*?>' set ft=xml" XXD outputelseif getline(1) =~ '^\x\{7}: \x\{2} \=\x\{2} \=\x\{2} \=\x\{2} ' set ft=xxd" RCS/CVS log outputelseif getline(1) =~ '^RCS file:' || getline(2) =~ '^RCS file:' set ft=rcslog" CVS commitelseif getline(2) =~ '^CVS:' set ft=cvs" SNNS fileselseif getline(1) =~ '^SNNS network definition file' set ft=snnsnetelseif getline(1) =~ '^SNNS pattern definition file' set ft=snnspatelseif getline(1) =~ '^SNNS result file' set ft=snnsres" Virataelseif getline(1) =~ '^%.\{-}[Vv]irata' \ || getline(2) =~ '^%.\{-}[Vv]irata' \ || getline(3) =~ '^%.\{-}[Vv]irata' \ || getline(4) =~ '^%.\{-}[Vv]irata' \ || getline(5) =~ '^%.\{-}[Vv]irata' set ft=virata" Website MetaLanguageelseif getline(1) =~ '^#!.*wml.*' set ft=wml" Straceelseif getline(1) =~ '^execve(' set ft=strace" VSE JCLelseif getline(1) =~ '^\* $$ JOB\>' || getline(1) =~ '^// *JOB\>' set ft=vsejcl" TAK and SINDAelseif getline(4) =~ 'K & K Associates' || getline(2) =~ 'TAK 2000' set ft=takoutelseif getline(3) =~ 'S Y S T E M S I M P R O V E D ' set ft=sindaoutelseif getline(6) =~ 'Run Date: ' set ft=takcmpelseif getline(9) =~ 'Node File 1' set ft=sindacmp" DNS zone fileselseif getline(1) =~ '\($ORIGIN\|$TTL\|IN\s*SOA\)' \ || getline(2) =~ '\($ORIGIN\|$TTL\|IN\s*SOA\)' \ || getline(1).getline(2).getline(3).getline(4) =~ 'BIND.*named' set ft=dns" Generic configuration file (check this last, it's just guessing!)elseif getline(1) =~ '^#' || getline(2) =~ '^#' || getline(3) =~ '^#' \ || getline(4) =~ '^#' || getline(5) =~ '^#' set ft=confendif" Restore 'cpoptions'let &cpo = scr_cpo_saveunlet scr_cpo_saveendif " !did_filetype()" vim: ts=8 tw=0 sts=0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -