2

While editing my vimrc I noticed that some keywords get highlighted at the beginning of lines, like Note: and Reminder:. I tried to find this syntax group in the vim.vim syntax file, but to no avail. I also looked through all the :help files I could think of. Does anyone have a complete list of these handy keywords? Which syntax file are they located in?

This question references a similar type of keyword that might be in the same list, if these words are not limited to Vimscript:

How do I add syntax keywords globally for any filetype?

1 Answer 1

1

If we look through :syn list we see some elements which are the same color as the highlighted words, in particular, vimCommentTitle. Using :syn list vimCommentTitle we see:

vimCommentTitle xxx match /"\s*\%([sS]:\|\h\w*#\)\=\u\w*\(\s\+\u\w*\)*:/hs=s+1  
contained contains=vimCommentTitleLeader,vimTodo,@vimCommentGroup
               links to PreProc

So the list of words is given by a regex, roughly:

  • Word:
  • s:Word:
  • S:Word:
  • He Llo World:
  • Hello#World:

and so on.

The purpose of this seems to be highlighting sections and function names in a vim script (although the pattern does not cover all possible function names). For example:

" Some Functions: {{{

" module#Function: this surely does something
fu! module#Function()
endf

" s:Func2: this does something privately
fu! s:Func2()
endf

" }}}
2
  • 1
    :echo synIDattr(synID(line('.'), col('.'), 1), 'name') is pretty useful to get the name of whatever is under the cursor (I have it as a command, since it's a bit hard to remember/type), then use :verbose hi <name> to find out where it was defined. Probably a bit easier than scanning through :syn list :-) Commented Apr 11, 2020 at 17:06
  • These are both very helpful, it will make it much easier to tweak highlighting.
    – Norbert-op
    Commented Apr 11, 2020 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.