📄 ptcap.vim
字号:
" Vim syntax file" Language: printcap/termcap database" Maintainer: Haakon Riiser <haakon@riiser.net>" Last Change: 2001 Apr 25" For version 5.x: Clear all syntax items" For version 6.x: Quit when a syntax file was already loadedif version < 600 syn clearelseif exists("b:current_syntax") finishendif" Since I only highlight based on the structure of the databases, not" specific keywords, case sensitivity isn't requiredsyn case ignore" Since everything that is not caught by the syntax patterns is assumed" to be an error, we start parsing 20 lines up, unless something else" is specifiedif exists("ptcap_minlines") exe "syn sync lines=".ptcap_minlineselse syn sync lines=20endif" Highlight everything that isn't caught by the rules as errors," except blank linessyn match ptcapError "^.*\S.*$"syn match ptcapLeadBlank "^\s\+" contained" `:' and `|' are delimiters for fields and names, and should not be" highlighted. Hence, they are linked to `NONE'syn match ptcapDelimiter "[:|]" contained" Escaped characters receive special highlightingsyn match ptcapEscapedChar "\\." containedsyn match ptcapEscapedChar "\^." containedsyn match ptcapEscapedChar "\\\o\{3}" contained" A backslash at the end of a line will suppress the newlinesyn match ptcapLineCont "\\$" contained" A number follows the same rules as an integer in Csyn match ptcapNumber "#\(+\|-\)\=\d\+"lc=1 containedsyn match ptcapNumberError "#\d*[^[:digit:]:\\]"lc=1 containedsyn match ptcapNumber "#0x\x\{1,8}"lc=1 containedsyn match ptcapNumberError "#0x\X"me=e-1,lc=1 containedsyn match ptcapNumberError "#0x\x\{9}"lc=1 containedsyn match ptcapNumberError "#0x\x*[^[:xdigit:]:\\]"lc=1 contained" The `@' operator clears a flag (i.e., sets it to zero)" The `#' operator assigns a following number to the flag" The `=' operator assigns a string to the preceding flagsyn match ptcapOperator "[@#=]" contained" Some terminal capabilites have special names like `#5' and `@1', and we" need special rules to match these properlysyn match ptcapSpecialCap "\W[#@]\d" contains=ptcapDelimiter contained" If editing a termcap file, an entry in the database is terminated by" a (non-escaped) newline. Otherwise, it is terminated by a line which" does not start with a colon (:)if exists("b:ptcap_type") && b:ptcap_type[0] == 't' syn region ptcapEntry start="^\s*[^[:space:]:]" end="[^\\]\(\\\\\)*$" end="^$" contains=ptcapNames,ptcapField,ptcapLeadBlank keependelse syn region ptcapEntry start="^\s*[^[:space:]:]"me=e-1 end="^\s*[^[:space:]:#]"me=e-1 contains=ptcapNames,ptcapField,ptcapLeadBlank,ptcapCommentendifsyn region ptcapNames start="^\s*[^[:space:]:]" skip="[^\\]\(\\\\\)*\\:" end=":"me=e-1 contains=ptcapDelimiter,ptcapEscapedChar,ptcapLineCont,ptcapLeadBlank,ptcapComment keepend containedsyn region ptcapField start=":" skip="[^\\]\(\\\\\)*\\$" end="[^\\]\(\\\\\)*:"me=e-1 end="$" contains=ptcapDelimiter,ptcapString,ptcapNumber,ptcapNumberError,ptcapOperator,ptcapLineCont,ptcapSpecialCap,ptcapLeadBlank,ptcapComment keepend containedsyn region ptcapString matchgroup=ptcapOperator start="=" skip="[^\\]\(\\\\\)*\\:" matchgroup=ptcapDelimiter end=":"me=e-1 matchgroup=NONE end="[^\\]\(\\\\\)*[^\\]$" end="^$" contains=ptcapEscapedChar,ptcapLineCont keepend containedsyn region ptcapComment start="^\s*#" end="$" contains=ptcapLeadBlankif version >= 508 || !exists("did_ptcap_syntax_inits") if version < 508 let did_ptcap_syntax_inits = 1 command -nargs=+ HiLink hi link <args> else command -nargs=+ HiLink hi def link <args> endif HiLink ptcapComment Comment HiLink ptcapDelimiter Delimiter " The highlighting of "ptcapEntry" should always be overridden by " its contents, so I use Todo highlighting to indicate that there " is work to be done with the syntax file if you can see it :-) HiLink ptcapEntry Todo HiLink ptcapError Error HiLink ptcapEscapedChar SpecialChar HiLink ptcapField Type HiLink ptcapLeadBlank NONE HiLink ptcapLineCont Special HiLink ptcapNames Label HiLink ptcapNumber NONE HiLink ptcapNumberError Error HiLink ptcapOperator Operator HiLink ptcapSpecialCap Type HiLink ptcapString NONE delcommand HiLinkendiflet b:current_syntax = "ptcap"" vim: sts=4 sw=4 ts=8
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -