📄 sh.vim
字号:
syn cluster shCommentGroup contains=shTodosyn match shComment "#.*$" contains=@shCommentGroup" String and Character constants"===============================syn match shNumber "-\=\<\d\+\>"syn match shSpecial contained "\\\d\d\d\|\\[abcfnrtv]"syn region shSinglequote matchgroup=shOperator start=+'+ end=+'+ contains=shStringSpecialsyn region shDoubleQuote matchgroup=shOperator start=+"+ skip=+\\"+ end=+"+ contains=@shDblQuoteList,shStringSpecialsyn match shStringSpecial contained "[^[:print:]]"syn match shSpecial "\\[\\\"\'`$]"" File redirection highlighted as operators"==========================================syn match shRedir "\d\=>\(&[-0-9]\)\="syn match shRedir "\d\=>>-\="syn match shRedir "\d\=<\(&[-0-9]\)\="syn match shRedir "\d<<-\="" Shell Input Redirection (Here Documents)if version < 600 syn region shHereDoc matchgroup=shRedir start="<<\s*\**END[a-zA-Z_0-9]*\**" matchgroup=shRedir end="^END[a-zA-Z_0-9]*$" syn region shHereDoc matchgroup=shRedir start="<<-\s*\**END[a-zA-Z_0-9]*\**" matchgroup=shRedir end="^\t*END[a-zA-Z_0-9]*$" syn region shHereDoc matchgroup=shRedir start="<<\s*\**EOF\**" matchgroup=shRedir end="^EOF$" syn region shHereDoc matchgroup=shRedir start="<<-\s*\**EOF\**" matchgroup=shRedir end="^\t*EOF$" syn region shHereDoc matchgroup=shRedir start="<<\s*\**\.\**" matchgroup=shRedir end="^\.$" syn region shHereDoc matchgroup=shRedir start="<<-\s*\**\.\**" matchgroup=shRedir end="^\t*\.$"else syn region shHereDoc matchgroup=shRedir start="<<\s*\**\z(\h\w*\)\**" matchgroup=shRedir end="^\z1$" syn region shHereDoc matchgroup=shRedir start="<<-\s*\**\z(\h\w*\)\**" matchgroup=shRedir end="^\t*\z1$"endif" Identifiers"============syn match shVariable "\<\h\w*="me=e-1 nextgroup=shSetIdentifiersyn match shIdWhiteSpace contained "\s"syn match shSetIdentifier contained "=" nextgroup=shString,shPatternif exists("b:is_bash") syn region shSetList matchgroup=shStatement start="\<\(declare\|typeset\|local\|export\|set\|unset\)\>[^/]"me=e-1 end="$" matchgroup=shOperator end="[;&]"me=e-1 matchgroup=NONE end="#\|="me=e-1 contains=@shIdListelseif exists("b:is_kornshell") syn region shSetList matchgroup=shStatement start="\<\(typeset\|set\|export\|unset\)\>[^/]"me=e-1 end="$" matchgroup=shOperator end="[;&]"me=e-1 matchgroup=NONE end="[#=]"me=e-1 contains=@shIdListelse syn region shSetList matchgroup=shStatement start="\<\(set\|export\|unset\)\>[^/]"me=e-1 end="$" matchgroup=shOperator end="[;&]" matchgroup=NONE end="[#=]"me=e-1 contains=@shIdListendif" The [^/] in the start pattern is a kludge to avoid bad" highlighting with cd /usr/local/lib...syn region shFunction transparent matchgroup=shFunctionName start="^\s*\<\h\w*\>\s*()\s*{" end="}" contains=ALLBUT,@shFunctionListsyn region shDeref oneline start="\${" end="}" contains=shDeref,shDerefVarsyn match shDeref "\$\h\w*\>"syn match shPosnParm "\$[-#@*$?!0-9]"syn match shDerefVar contained "\d\+\>" nextgroup=shDerefOp,shDerefError,shDerefOpError,shExprsyn match shDerefVar contained "\h\w*\>" nextgroup=shDerefOp,shDerefError,shDerefOpError,shExprif exists("b:is_bash") syn match shDerefVar contained "[-@*?!]" nextgroup=shDerefOp,shDerefError,shDerefOpError,shExprelse syn match shDerefVar contained "[-#@*?!]" nextgroup=shDerefOp,shDerefError,shDerefOpError,shExprendifsyn match shDerefVar contained "\$[^{(]"me=s+1 nextgroup=shDerefOp,shDerefError,shDerefOpError,shExprsyn match shDerefOpError contained "[^:}[]"syn match shDerefOp contained ":\=[-=?+]" nextgroup=shDerefTextsyn region shDerefText contained start="[^{}]" end="}"me=e-1 contains=shDeref,shCommandSub,shDoubleQuote,shSingleQuote,shDerefTextErrorsyn match shDerefTextError contained "^."syn match shDerefError contained "\s.\{-}}"me=e-1syn region shDerefText contained start="{" end="}" contains=shDeref,shCommandSubif exists("b:is_kornshell") || exists("b:is_bash") syn match shDerefVar contained "#\(\d\+\|\h\w*\)" nextgroup=shDerefOp,shDerefError,shDerefOpError,shExpr syn match shDerefOp contained "##\|%%\|[#%]" nextgroup=shDerefTextendif" A bunch of useful sh keywordssyn keyword shStatement break eval newgrp return ulimitsyn keyword shStatement cd exec pwd shift umasksyn keyword shStatement chdir exit read test waitsyn keyword shStatement continue kill readonly trapsyn keyword shConditional elif else then whileif exists("b:is_kornshell") || exists("b:is_bash") syn keyword shFunction function syn keyword shRepeat select until syn keyword shStatement alias fg integer printf times syn keyword shStatement autoload functions jobs r true syn keyword shStatement bg getopts let stop type syn keyword shStatement false hash nohup suspend unalias syn keyword shStatement fc history print time whence if exists("b:is_bash") syn keyword shStatement bind disown help popd shopt syn keyword shStatement builtin enable logout pushd source syn keyword shStatement dirs else syn keyword shStatement login newgrp endifendif" Syncs" =====if !exists("sh_minlines") let sh_minlines = 200endifif !exists("sh_maxlines") let sh_maxlines = 2 * sh_minlinesendifexec "syn sync minlines=" . sh_minlines . " maxlines=" . sh_maxlinessyn sync match shDoSync grouphere shDo "\<do\>"syn sync match shDoSync groupthere shDo "\<done\>"syn sync match shIfSync grouphere shIf "\<if\>"syn sync match shIfSync groupthere shIf "\<fi\>"syn sync match shForSync grouphere shFor "\<for\>"syn sync match shForSync groupthere shFor "\<in\>"syn sync match shCaseEsacSync grouphere shCaseEsac "\<case\>"syn sync match shCaseEsacSync groupthere shCaseEsac "\<esac\>"" The default highlighting.hi def link shArithRegion shShellVariableshi def link shCaseBar shConditionalhi def link shCaseIn shConditionalhi def link shCaseStart shConditionalhi def link shCmdSubRegion shShellVariableshi def link shColon shStatementhi def link shDeref shShellVariableshi def link shDerefOp shOperatorhi def link shDerefVar shShellVariableshi def link shDoubleQuote shStringhi def link shEcho shStringhi def link shEmbeddedEcho shStringhi def link shHereDoc shStringhi def link shOption shCommandSubhi def link shPattern shStringhi def link shPosnParm shShellVariableshi def link shRedir shOperatorhi def link shSinglequote shStringhi def link shSource shOperatorhi def link shStringSpecial shSpecialhi def link shSubShRegion shOperatorhi def link shTestOpr shConditionalhi def link shVariable shSetListhi def link shWrapLineOperator shOperatorif exists("b:is_bash") hi def link bashAdminStatement shStatement hi def link bashSpecialVariables shShellVariables hi def link bashStatement shStatementendifif exists("b:is_kornshell") hi def link kshSpecialVariables shShellVariables hi def link kshStatement shStatementendifhi def link shCaseError Errorhi def link shCurlyError Errorhi def link shDerefError Errorhi def link shDerefOpError Errorhi def link shDerefTextError Errorhi def link shDoError Errorhi def link shEsacError Errorhi def link shIfError Errorhi def link shInError Errorhi def link shParenError Errorhi def link shTestError Errorif exists("b:is_kornshell") hi def link shDTestError Errorendifhi def link shArithmetic Specialhi def link shCharClass Identifierhi def link shCommandSub Specialhi def link shComment Commenthi def link shConditional Conditionalhi def link shExprRegion Delimiterhi def link shFunction Functionhi def link shFunctionName Functionhi def link shNumber Numberhi def link shOperator Operatorhi def link shRepeat Repeathi def link shSetList Identifierhi def link shShellVariables PreProchi def link shSpecial Specialhi def link shStatement Statementhi def link shString Stringhi def link shTodo Todo" Current Syntax" ==============if exists("b:is_bash") let b:current_syntax = "bash"elseif exists("b:is_kornshell") let b:current_syntax = "ksh"else let b:current_syntax = "sh"endif" vim: ts=15
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -