📄 tex.vim
字号:
" Vim syntax file" Language: TeX" Version: 6.0-8" Maintainer: Dr. Charles E. Campbell, Jr. <Charles.E.Campbell.1@gsfc.nasa.gov>" Last Change: May 16, 2001"" Notes:"" 1. If you have a \begin{verbatim} that appears to overrun its boundaries," use %stopzone."" 2. Run-on equations ($..$ and $$..$$, particularly) can also be stopped" by suitable use of %stopzone."" 3. If you have a slow computer, you may wish to modify"" syn sync maxlines=200" syn sync minlines=50"" to values that are more to your liking."" 4. There is no match-syncing for $...$ and $$...$$; hence large" equation blocks constructed that way may exhibit syncing problems." (there's no difference between begin/end patterns)"" 5. If you have the variable "tex_no_error" defined then none of the" lexical error-checking will be done."" ie. let tex_no_error=1" For version 5.x: Clear all syntax items" For version 6.x: Quit when a syntax file was already loadedif version < 600 syntax clearelseif exists("b:current_syntax") finishendif" (La)TeX keywords only use the letters a-zA-Z" but _ is the only one that causes problems.let b:extfname=expand("%:e")if version < 600 set isk-=_ if b:extfname == "sty" || b:extfname == "cls" || b:extfname == "clo" || b:extfname == "dtx" || b:extfname == "ltx" set isk+=@ endifelse setlocal isk-=_ if b:extfname == "sty" || b:extfname == "cls" || b:extfname == "clo" || b:extfname == "dtx" || b:extfname == "ltx" setlocal isk+=@ endifendif" Clusters" --------syn cluster texCmdGroup contains=texCmdBody,texComment,texDefParm,texDelimiter,texDocType,texInput,texLength,texLigature,texMathDelim,texMathError,texMathOper,texNewCmd,texNewEnv,texRefZone,texSection,texSectionMarker,texSectionName,texSpecialChar,texStatement,texString,texTypeSize,texTypeStylesyn cluster texEnvGroup contains=texMatcher,texMathDelim,texSpecialChar,texStatementsyn cluster texMatchGroup contains=@texMathZones,texAccent,texBadMath,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMatcher,texNewCmd,texNewEnv,texOnlyMath,texParen,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZone,texInputFilesyn cluster texMathDelimGroup contains=texMathDelimBad,texMathDelimKey,texMathDelimSet1,texMathDelimSet2syn cluster texMathMatchGroup contains=@texMathZones,texComment,texDefCmd,texDelimiter,texDocType,texInput,texLength,texLigature,texMathDelim,texMathError,texMathMatcher,texMathOper,texNewCmd,texNewEnv,texRefZone,texSection,texSpecialChar,texStatement,texString,texTypeSize,texTypeStyle,texZonesyn cluster texMathZoneGroup contains=texComment,texDelimiter,texLength,texMathDelim,texMathError,texMathMatcher,texMathOper,texRefZone,texSpecialChar,texStatement,texTypeSize,texTypeStylesyn cluster texMathZones contains=texMathZoneA,texMathZoneB,texMathZoneC,texMathZoneD,texMathZoneE,texMathZoneF,texMathZoneG,texMathZoneH,texMathZoneI,texMathZoneJ,texMathZoneK,texMathZoneL,texMathZoneM,texMathZoneN,texMathZoneO,texMathZoneP,texMathZoneQ,texMathZoneR,texMathZoneS,texMathZoneT,texMathZoneU,texMathZoneV,texMathZoneW" Try to flag {} and () mismatchessyn region texMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\[{}]" end="}" contains=@texMatchGroup,texErrorsyn region texMatcher matchgroup=Delimiter start="\[" end="]" contains=@texMatchGroup,texErrorsyn region texParen start="(" end=")" contains=@texMatchGroupsyn match texError "[}\])]"syn match texMathError "}" containedsyn region texMathMatcher matchgroup=Delimiter start="{" skip="\\\\\|\\}" end="}" end="%stopzone\>" contained contains=@texMathMatchGroup" TeX/LaTeX keywords" Instead of trying to be All Knowing, I just match \..alphameric.." Note that *.tex files may not have "@" in their \commandsif b:extfname == "sty" || b:extfname == "cls" || b:extfname == "clo" || b:extfname == "dtx" || b:extfname == "ltx" syn match texStatement "\\[a-zA-Z@]\+"else syn match texStatement "\\\a\+" syn match texError "\\\a*@[a-zA-Z@]*"endif" TeX/LaTeX delimiterssyn match texDelimiter "&"syn match texDelimiter "\\\\"" texAccent (tnx to Karim Belabas) avoids annoying highlighting for accentsif b:extfname == "sty" || b:extfname == "cls" || b:extfname == "clo" || b:extfname == "dtx" || b:extfname == "ltx" syn match texAccent "\\[bcdvuH][^a-zA-Z@]"me=e-1 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)[^a-zA-Z@]"me=e-1else syn match texAccent "\\[bcdvuH]\A"me=e-1 syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)\A"me=e-1endifsyn match texAccent "\\[bcdvuH]$"syn match texAccent +\\[=^.\~"`']+syn match texAccent +\\['=t'.c^ud"vb~Hr]{\a}+syn match texLigature "\\\([ijolL]\|ae\|oe\|ss\|AA\|AE\|OE\)$"" \begin{}/\end{} section markerssyn match texSectionMarker "\\begin\>\|\\end\>" nextgroup=texSectionNamesyn region texSectionName matchgroup=Delimiter start="{" end="}" contained" \documentclass, \documentstyle, \usepackagesyn match texDocType "\\documentclass\>\|\\documentstyle\>\|\\usepackage\>" nextgroup=texSectionName,texDocTypeArgssyn region texDocTypeArgs matchgroup=Delimiter start="\[" end="]" contained nextgroup=texSectionName" TeX inputsyn match texInput "\\input\s\+[a-zA-Z/.0-9_^]\+"hs=s+7 contains=texStatementsyn match texInputFile "\\include\(graphics\|list\)\=\(\[.\{-}\]\)\=\s*{.\{-}}" contains=texStatement,texInputCurliessyn match texInputFile "\\\(epsfig\|input\|usepackage\)\s*\(\[.*\]\)\={.\{-}}" contains=texStatement,texInputCurlies,texInputFileOptsyn match texInputCurlies "[{}]" containedsyn region texInputFileOpt matchgroup=Delimiter start="\[" end="\]" contained" Type Styles (LaTeX 2.09)syn match texTypeStyle "\\rm\>"syn match texTypeStyle "\\em\>"syn match texTypeStyle "\\bf\>"syn match texTypeStyle "\\it\>"syn match texTypeStyle "\\sl\>"syn match texTypeStyle "\\sf\>"syn match texTypeStyle "\\sc\>"syn match texTypeStyle "\\tt\>"" Type Styles: attributes, commands, families, etc (LaTeX2E)syn match texTypeStyle "\\textbf\>"syn match texTypeStyle "\\textit\>"syn match texTypeStyle "\\textmd\>"syn match texTypeStyle "\\textrm\>"syn match texTypeStyle "\\textsc\>"syn match texTypeStyle "\\textsf\>"syn match texTypeStyle "\\textsl\>"syn match texTypeStyle "\\texttt\>"syn match texTypeStyle "\\textup\>"syn match texTypeStyle "\\mathbf\>"syn match texTypeStyle "\\mathcal\>"syn match texTypeStyle "\\mathit\>"syn match texTypeStyle "\\mathnormal\>"syn match texTypeStyle "\\mathrm\>"syn match texTypeStyle "\\mathsf\>"syn match texTypeStyle "\\mathtt\>"syn match texTypeStyle "\\rmfamily\>"syn match texTypeStyle "\\sffamily\>"syn match texTypeStyle "\\ttfamily\>"syn match texTypeStyle "\\itshape\>"syn match texTypeStyle "\\scshape\>"syn match texTypeStyle "\\slshape\>"syn match texTypeStyle "\\upshape\>"syn match texTypeStyle "\\bfseries\>"syn match texTypeStyle "\\mdseries\>"" Some type sizessyn match texTypeSize "\\tiny\>"syn match texTypeSize "\\scriptsize\>"syn match texTypeSize "\\footnotesize\>"syn match texTypeSize "\\small\>"syn match texTypeSize "\\normalsize\>"syn match texTypeSize "\\large\>"syn match texTypeSize "\\Large\>"syn match texTypeSize "\\LARGE\>"syn match texTypeSize "\\huge\>"syn match texTypeSize "\\Huge\>"" Spacecodessyn match texSpaceCode "\\\(math\|cat\|del\|lc\|sf\|uc\)code`"me=e-1 nextgroup=texSpaceCodeCharsyn match texSpaceCodeChar "`.\{-}="me=e-1" Sections, subsections, etcsyn match texSection "\\\(sub\)*section\*\=\>"syn match texSection "\\\(title\|author\|part\|chapter\|paragraph\|subparagraph\)\>"syn match texSection "\\begin\s*{\s*abstract\s*}\|\\end\s*{\s*abstract\s*}"" Bad Math (mismatched)syn match texBadMath "\\end\s*{\s*\(split\|align\|gather\|alignat\|flalign\|multline\)\s*}"syn match texBadMath "\\end\s*{\s*\(equation\|eqnarray\|displaymath\)\*\=\s*}"syn match texBadMath "\\[\])]"" Math Zonessyn region texMathZoneA start="\\begin\s*{\s*align\*\s*}" end="\\end\s*{\s*align\*\s*}" keepend contains=@texMathZoneGroupsyn region texMathZoneB start="\\begin\s*{\s*alignat\*\s*}" end="\\end\s*{\s*alignat\*\s*}" keepend contains=@texMathZoneGroupsyn region texMathZoneC start="\\begin\s*{\s*alignat\s*}" end="\\end\s*{\s*alignat\s*}" keepend contains=@texMathZoneGroupsyn region texMathZoneD start="\\begin\s*{\s*align\s*}" end="\\end\s*{\s*align\s*}" keepend contains=@texMathZoneGroupsyn region texMathZoneE start="\\begin\s*{\s*eqnarray\*\s*}" end="\\end\s*{\s*eqnarray\*\s*}" keepend contains=@texMathZoneGroupsyn region texMathZoneF start="\\begin\s*{\s*eqnarray\s*}" end="\\end\s*{\s*eqnarray\s*}" keepend contains=@texMathZoneGroupsyn region texMathZoneG start="\\begin\s*{\s*equation\*\s*}" end="\\end\s*{\s*equation\*\s*}" keepend contains=@texMathZoneGroupsyn region texMathZoneH start="\\begin\s*{\s*equation\s*}" end="\\end\s*{\s*equation\s*}" keepend contains=@texMathZoneGroupsyn region texMathZoneI start="\\begin\s*{\s*flalign\*\s*}" end="\\end\s*{\s*flalign\*\s*}" keepend contains=@texMathZoneGroupsyn region texMathZoneJ start="\\begin\s*{\s*flalign\s*}" end="\\end\s*{\s*flalign\s*}" keepend contains=@texMathZoneGroupsyn region texMathZoneK start="\\begin\s*{\s*gather\*\s*}" end="\\end\s*{\s*gather\*\s*}" keepend contains=@texMathZoneGroupsyn region texMathZoneL start="\\begin\s*{\s*gather\s*}" end="\\end\s*{\s*gather\s*}" keepend contains=@texMathZoneGroupsyn region texMathZoneM start="\\begin\s*{\s*math\*\s*}" end="\\end\s*{\s*math\*\s*}" keepend contains=@texMathZoneGroupsyn region texMathZoneN start="\\begin\s*{\s*math\s*}" end="\\end\s*{\s*math\s*}" keepend contains=@texMathZoneGroupsyn region texMathZoneO start="\\begin\s*{\s*multline\s*}" end="\\end\s*{\s*multline\s*}" keepend contains=@texMathZoneGroupsyn region texMathZoneP start="\\begin\s*{\s*split\s*}" end="\\end\s*{\s*split\s*}" keepend contains=@texMathZoneGroupsyn region texMathZoneQ start="\\begin\s*{\s*displaymath\*\s*}" end="\\end\s*{\s*displaymath\*\s*}" keepend contains=@texMathZoneGroupsyn region texMathZoneR start="\\begin\s*{\s*displaymath\s*}" end="\\end\s*{\s*displaymath\s*}" keepend contains=@texMathZoneGroupsyn region texMathZoneS start="\\begin\s*{\s*multline\*\s*}" end="\\end\s*{\s*multline\*\s*}" keepend contains=@texMathZoneGroupsyn region texMathZoneT matchgroup=Delimiter start="\\(" matchgroup=Delimiter end="\\)\|%stopzone\>" keepend contains=@texMathZoneGroupsyn region texMathZoneU matchgroup=Delimiter start="\\\[" matchgroup=Delimiter end="\\]\|%stopzone\>" keepend contains=@texMathZoneGroupsyn region texMathZoneV matchgroup=Delimiter start="\$" skip="\\\\\|\\\$" matchgroup=Delimiter end="\$" end="%stopzone\>" contains=@texMathZoneGroupsyn region texMathZoneW matchgroup=Delimiter start="\$\$" matchgroup=Delimiter end="\$\$" end="%stopzone\>" keepend contains=@texMathZoneGroupsyn match texMathOper "[_^=]" contained" \left..something.. and \right..something.. supportsyn match texMathDelimBad contained "."syn match texMathDelim "\\\(left\|right\)\>" nextgroup=texMathDelimSet1,texMathDelimSet2,texMathDelimBadsyn match texMathDelim "\\\(left\|right\)arrow\>"syn match texMathDelim "\\lefteqn\>"syn match texMathDelimSet2 contained "\\" nextgroup=texMathDelimKey,texMathDelimBadsyn match texMathDelimSet1 contained "[<>()[\]|/.]\|\\[{}|]"syn keyword texMathDelimKey contained Downarrow backslash lceil rceil uparrowsyn keyword texMathDelimKey contained Uparrow downarrow lfloor rfloor updownarrowsyn keyword texMathDelimKey contained Updownarrow langle rangle" special TeX characters ( \$ \& \% \# \{ \} \_ \S \P )syn match texSpecialChar "\\[$&%#{}_]"if b:extfname == "sty" || b:extfname == "cls" || b:extfname == "clo" || b:extfname == "dtx" || b:extfname == "ltx" syn match texSpecialChar "\\[SP@][^a-zA-Z@]"me=e-1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -