help.vim (11922B)
1 " Vim syntax file 2 " Language: Vim help file 3 " Maintainer: Doug Kearns <dougkearns@gmail.com> 4 " Former Maintainer: Bram Moolenaar <Bram@vim.org> 5 " Last Change: 2026 Aug 24 6 7 " Quit when a (custom) syntax file was already loaded 8 if exists("b:current_syntax") 9 finish 10 endif 11 12 let s:cpo_save = &cpo 13 set cpo&vim 14 15 syn iskeyword @,48-57,_,192-255 16 17 if !exists('g:help_example_languages') 18 let g:help_example_languages = #{ vim: 'vim', vim9: 'vim' } 19 endif 20 21 syn match helpHeadline "^[A-Z.][-A-Z0-9 .,()_']*?\=\ze\(\s\+\*\|$\)" 22 syn match helpSectionDelim "^===.*===$" 23 syn match helpSectionDelim "^---.*--$" 24 25 if has("conceal") 26 syn region helpExample matchgroup=helpIgnore 27 \ start="\%(^\| \)>[a-z0-9]*$" end="^[^ \t]"me=e-1 end="^<" concealends 28 else 29 syn region helpExample matchgroup=helpIgnore 30 \ start="\%(^\| \)>[a-z0-9]*$" end="^[^ \t]"me=e-1 end="^<" 31 endif 32 33 for [s:lang, s:syntax] in g:help_example_languages->items() 34 unlet! b:current_syntax 35 36 if s:lang == "vim9" 37 let b:vimsyn_force_vim9script = v:true 38 endif 39 40 " silent! to prevent E403 41 execute 'silent! syn include' $'@helpExampleHighlight_{s:lang}' 42 \ $'syntax/{s:syntax}.vim' 43 44 if s:lang == "vim9" 45 unlet b:vimsyn_force_vim9script 46 endif 47 48 execute $'syn region helpExampleHighlight_{s:lang} matchgroup=helpIgnore' 49 \ $'start=/\%(^\| \)>{s:lang}$/' 50 \ 'end=/^[^ \t]/me=e-1 end=/^</' 51 \ (has("conceal") ? 'concealends' : '') 52 \ $'contains=@helpExampleHighlight_{s:lang} keepend' 53 endfor 54 unlet! s:lang s:syntax 55 56 if has_key(g:help_example_languages, "vim9") 57 " for example at :help vim9-mix 58 syn region vim9LegacyHeader_HelpExample 59 \ start=+" _legacy Vim script_ comments are placed here+ 60 \ end="^\ze\s*vim9s\%[cript]\>" 61 \ contains=@vimLegacyTop,vimComment,vimLineComment,vimLineStart 62 syn cluster helpExampleHighlight_vim9 add=vim9LegacyHeader_HelpExample 63 endif 64 65 if has("ebcdic") 66 syn match helpHyperTextJump "\\\@<!|[^"*|]\+|" contains=helpBar 67 syn match helpHyperTextEntry "\*[^"*|]\+\*\s"he=e-1 contains=helpStar 68 syn match helpHyperTextEntry "\*[^"*|]\+\*$" contains=helpStar 69 else 70 syn match helpHyperTextJump "\\\@<!|[#-)!+-~]\+|" contains=helpBar 71 syn match helpHyperTextEntry "\*[#-)!+-~]\+\*\s"he=e-1 contains=helpStar 72 syn match helpHyperTextEntry "\*[#-)!+-~]\+\*$" contains=helpStar 73 endif 74 if has("conceal") 75 syn match helpBar contained "|" conceal 76 syn match helpBacktick contained "`" conceal 77 syn match helpStar contained "\*" conceal 78 else 79 syn match helpBar contained "|" 80 syn match helpBacktick contained "`" 81 syn match helpStar contained "\*" 82 endif 83 syn match helpNormal "|.*====*|" 84 syn match helpNormal "|||" 85 syn match helpNormal ":|vim:|" " for :help modeline 86 syn match helpVim "\<Vim version [0-9][0-9.a-z]*" 87 syn match helpVim "^\s\+\zsVIM - main help file$" 88 syn region helpVim start="^\s\+VIM REFERENCE" end="^$" 89 syn region helpVim start="^\s\+VIM USER MANUAL" end="^$" 90 syn match helpOption "'[a-z]\{2,\}'" 91 syn match helpOption "'t_..'" 92 syn match helpNormal "'ab'" 93 syn match helpCommand "`[^` \t]\+`"hs=s+1,he=e-1 contains=helpBacktick 94 " doesn't allow a . directly after an ending backtick. See :helpgrep `[^`,]\+ [^`,]\+`\. 95 syn match helpCommand "\(^\|[^a-z"[]\)\zs`[^`]\+`\ze\([^a-z\t."']\|[.?!]\?$\)"hs=s+1,he=e-1 contains=helpBacktick 96 syn match helpHeader "\s*\zs.\{-}\ze\s\=\~$" nextgroup=helpIgnore 97 syn match helpGraphic ".* \ze`$" nextgroup=helpIgnore 98 if has("conceal") 99 syn match helpIgnore "." contained conceal 100 else 101 syn match helpIgnore "." contained 102 endif 103 104 " match 'iskeyword' word boundaries, '!-~,^*,^|,^",192-255' 105 let s:iskeyword = '!#-)+-{}~\d192-\d255' 106 let s:start_word = $'\%(^\|[^{s:iskeyword}]\)\@1<=' 107 let s:end_word = $'\%([^{s:iskeyword}]\|$\)\@=' 108 109 exec $'syn match helpNote "{s:start_word}\%(note\|Note\|NOTE\|Notes\):\={s:end_word}"' 110 exec $'syn match helpNote "\c[[(]note\%(:\|{s:end_word}\)"ms=s+1' 111 exec $'syn match helpWarning "{s:start_word}\%(WARNING:\=\|Warning:\){s:end_word}"' 112 exec $'syn match helpDeprecated "{s:start_word}\%(DEPRECATED:\=\|Deprecated:\){s:end_word}"' 113 exec $'syn match helpSpecial "{s:start_word}N{s:end_word}"' 114 exec $'syn match helpSpecial "{s:start_word}N\.$"me=e-1' 115 exec $'syn match helpSpecial "{s:start_word}N\.\s"me=e-2' 116 exec $'syn match helpSpecial "(N{s:end_word}"ms=s+1' 117 syn match helpSpecial "\[N]" 118 " avoid highlighting N N in quickref.txt 119 syn match helpSpecial "N N"he=s+1 120 syn match helpSpecial "Nth"me=e-2 121 syn match helpSpecial "N-1"me=e-2 122 " highlighting N for :resize in windows.txt 123 exec $'syn match helpSpecial "] -N{s:end_word}"ms=s+3' 124 exec $'syn match helpSpecial "+N{s:end_word}"ms=s+1' 125 exec $'syn match helpSpecial "\[+-]N{s:end_word}"ms=s+4' 126 127 unlet s:iskeyword s:start_word s:end_word 128 129 " highlighting N of cinoptions-values in indent.txt 130 syn match helpSpecial "^\t-\?\zsNs\?\s"me=s+1 131 " highlighting N of cinoptions-values in indent.txt 132 syn match helpSpecial "^\t[>enf{}^L:=lbghNEpti+cC/(uUwWkmMjJ)*#P]N\s"ms=s+2,me=e-1 133 syn match helpSpecial "{[-a-zA-Z0-9'"*+/:%#=[\]<>.,]\+}" 134 syn match helpSpecial "\s\[[-a-z^A-Z0-9_]\{2,}]"ms=s+1 135 syn match helpSpecial "<[-a-zA-Z0-9_]\+>" 136 syn match helpSpecial "<buffer=\w\+>" 137 syn match helpSpecial "<[SCM]-.>" 138 syn match helpNormal "<---*>" 139 syn match helpSpecial "\[range]" 140 syn match helpSpecial "\[line]" 141 syn match helpSpecial "\[count]" 142 syn match helpSpecial "\[offset]" 143 syn match helpSpecial "\[cmd]" 144 syn match helpNormal "vim9\[cmd]" 145 syn match helpSpecial "\[num]" 146 syn match helpSpecial "\[+num]" 147 syn match helpSpecial "\[-num]" 148 syn match helpSpecial "\[+cmd]" 149 syn match helpSpecial "\[++opt]" 150 syn match helpSpecial "\[++once]" 151 syn match helpSpecial "\[++nested]" 152 syn match helpSpecial "\[++t]" 153 syn match helpSpecial "\[arg]" 154 syn match helpSpecial "\[arguments]" 155 syn match helpSpecial "\[ident]" 156 syn match helpSpecial "\[addr]" 157 syn match helpSpecial "\[group]" 158 " Don't highlight [converted] and others that do not have a tag 159 syn match helpNormal "\[\(readonly\|fifo\|socket\|converted\|crypted\)]" 160 161 syn match helpSpecial "CTRL-." 162 syn match helpSpecial "CTRL-<\a\+>" 163 syn match helpSpecial "CTRL-SHIFT-." 164 syn match helpSpecial "CTRL-Break" 165 syn match helpSpecial "CTRL-PageUp" 166 syn match helpSpecial "CTRL-PageDown" 167 syn match helpSpecial "CTRL-Insert" 168 syn match helpSpecial "CTRL-Del" 169 syn match helpSpecial "CTRL-{char}" 170 syn region helpNotVi start="{Vi[: ]" start="{not" start="{only" end="}" contains=helpLeadBlank,helpHyperTextJump 171 syn match helpLeadBlank "^\s\+" contained 172 173 " Highlight group items in their own color. 174 syn match helpComment "\t[* ]Comment\t\+[a-z].*" 175 syn match helpConstant "\t[* ]Constant\t\+[a-z].*" 176 syn match helpString "\t[* ]String\t\+[a-z].*" 177 syn match helpCharacter "\t[* ]Character\t\+[a-z].*" 178 syn match helpNumber "\t[* ]Number\t\+[a-z].*" 179 syn match helpBoolean "\t[* ]Boolean\t\+[a-z].*" 180 syn match helpRegexp "\t[* ]Regexp\t\+[a-z].*" 181 syn match helpFloat "\t[* ]Float\t\+[a-z].*" 182 syn match helpIdentifier "\t[* ]Identifier\t\+[a-z].*" 183 syn match helpFunction "\t[* ]Function\t\+[a-z].*" 184 syn match helpStatement "\t[* ]Statement\t\+[a-z].*" 185 syn match helpConditional "\t[* ]Conditional\t\+[a-z].*" 186 syn match helpRepeat "\t[* ]Repeat\t\+[a-z].*" 187 syn match helpLabel "\t[* ]Label\t\+[a-z].*" 188 syn match helpOperator "\t[* ]Operator\t\+["a-z].*" 189 syn match helpKeyword "\t[* ]Keyword\t\+[a-z].*" 190 syn match helpException "\t[* ]Exception\t\+[a-z].*" 191 syn match helpPreProc "\t[* ]PreProc\t\+[a-z].*" 192 syn match helpInclude "\t[* ]Include\t\+[a-z].*" 193 syn match helpDefine "\t[* ]Define\t\+[a-z].*" 194 syn match helpMacro "\t[* ]Macro\t\+[a-z].*" 195 syn match helpPreCondit "\t[* ]PreCondit\t\+[a-z].*" 196 syn match helpType "\t[* ]Type\t\+[a-z].*" 197 syn match helpStorageClass "\t[* ]StorageClass\t\+[a-z].*" 198 syn match helpStructure "\t[* ]Structure\t\+[a-z].*" 199 syn match helpTypedef "\t[* ]Typedef\t\+[Aa-z].*" 200 syn match helpSpecial "\t[* ]Special\t\+[a-z].*" 201 syn match helpSpecialChar "\t[* ]SpecialChar\t\+[a-z].*" 202 syn match helpTag "\t[* ]Tag\t\+[a-z].*" 203 syn match helpDelimiter "\t[* ]Delimiter\t\+[a-z].*" 204 syn match helpSpecialComment "\t[* ]SpecialComment\t\+[a-z].*" 205 syn match helpDebug "\t[* ]Debug\t\+[a-z].*" 206 syn match helpUnderlined "\t[* ]Underlined\t\+[a-z].*" 207 syn match helpBold "\t[* ]Bold\t\+[a-z].*" 208 syn match helpItalic "\t[* ]Italic\t\+[a-z].*" 209 syn match helpBoldItalic "\t[* ]BoldItalic\t\+[a-z].*" 210 syn match helpError "\t[* ]Error\t\+[a-z].*" 211 syn match helpTodo "\t[* ]Todo\t\+[a-z].*" 212 213 syn match helpURL `\v<(((https?|ftp|gopher)://|(mailto|file|news):)[^'" \t<>{}]+|(www|web|w3)[a-z0-9_-]*\.[a-z0-9._-]+\.[^'" \t<>{}]+)[a-zA-Z0-9/]` 214 215 syn match helpDiffAdded "\t[* ]Added\t\+[a-z].*" 216 syn match helpDiffChanged "\t[* ]Changed\t\+[a-z].*" 217 syn match helpDiffRemoved "\t[* ]Removed\t\+[a-z].*" 218 219 " builtin.txt 220 syn region helpReturnType 221 \ start="^\t\tReturn type: " 222 \ end="^$" 223 \ contains=@vimType,helpHyperTextJump,helpSpecial 224 \ transparent 225 syn match helpSpecial contained "{type}" containedin=vimCompoundType 226 227 " digraph.txt 228 syn region helpDigraphTable 229 \ start="*digraph-table\%(-mbyte\)\=\*" 230 \ end="^$" 231 \ contains=helpHyperTextEntry,helpHeader 232 233 " various.txt 234 syn region helpExCommand_Version 235 \ start="^:ve\[rsion]\t\t" 236 \ end="\n\ze\n:ve\[rsion] {nr}" 237 \ contains=helpHyperTextEntry,helpHyperTextJump,helpOption 238 239 " Additionally load a language-specific syntax file "help_ab.vim". 240 let s:i = match(expand("%"), '\.\a\ax$') 241 if s:i > 0 242 exe "runtime syntax/help_" . strpart(expand("%"), s:i + 1, 2) . ".vim" 243 endif 244 unlet s:i 245 246 syn sync minlines=40 247 248 " Define the default highlighting. 249 " Only used when an item doesn't have highlighting yet 250 hi def link helpIgnore Ignore 251 hi def link helpHyperTextJump Identifier 252 hi def link helpBar Ignore 253 hi def link helpBacktick Ignore 254 hi def link helpStar Ignore 255 hi def link helpHyperTextEntry String 256 hi def link helpHeadline Statement 257 hi def link helpHeader PreProc 258 hi def link helpSectionDelim PreProc 259 hi def link helpVim Identifier 260 hi def link helpCommand Comment 261 hi def link helpExample Comment 262 hi def link helpOption Type 263 hi def link helpNotVi Special 264 hi def link helpSpecial Special 265 hi def link helpNote Todo 266 hi def link helpWarning Todo 267 hi def link helpDeprecated Todo 268 269 hi def link helpComment Comment 270 hi def link helpConstant Constant 271 hi def link helpString String 272 hi def link helpCharacter Character 273 hi def link helpNumber Number 274 hi def link helpBoolean Boolean 275 hi def link helpRegexp Regexp 276 hi def link helpFloat Float 277 hi def link helpIdentifier Identifier 278 hi def link helpFunction Function 279 hi def link helpStatement Statement 280 hi def link helpConditional Conditional 281 hi def link helpRepeat Repeat 282 hi def link helpLabel Label 283 hi def link helpOperator Operator 284 hi def link helpKeyword Keyword 285 hi def link helpException Exception 286 hi def link helpPreProc PreProc 287 hi def link helpInclude Include 288 hi def link helpDefine Define 289 hi def link helpMacro Macro 290 hi def link helpPreCondit PreCondit 291 hi def link helpType Type 292 hi def link helpStorageClass StorageClass 293 hi def link helpStructure Structure 294 hi def link helpTypedef Typedef 295 hi def link helpSpecialChar SpecialChar 296 hi def link helpTag Tag 297 hi def link helpDelimiter Delimiter 298 hi def link helpSpecialComment SpecialComment 299 hi def link helpDebug Debug 300 hi def link helpUnderlined Underlined 301 hi def link helpBold Bold 302 hi def link helpItalic Italic 303 hi def link helpBoldItalic BoldItalic 304 hi def link helpError Error 305 hi def link helpTodo Todo 306 hi def link helpURL String 307 hi def link helpDiffAdded Added 308 hi def link helpDiffChanged Changed 309 hi def link helpDiffRemoved Removed 310 311 if has('textprop') && expand('%:p') =~? '[/\\]doc[/\\]syntax.\(txt\|\a\ax\)$' 312 " highlight groups with their respective color 313 import 'dist/vimhelp.vim' 314 call vimhelp.HighlightGroups() 315 endif 316 317 let b:current_syntax = "help" 318 319 let &cpo = s:cpo_save 320 unlet s:cpo_save 321 " vim: ts=8 sw=2