Since I usually use a blank line to denote start of a new codeblock (function, class, etc.) I defined the following syntax rule.

The intent is to make the first line of a code block standout.

While the pattern works, It replaces the color coding of the individual keywords in the line with a white color. What is the best way to ensure that the color is retained?

syntax region BlankLine start='^\s*$' end='^\s*\S.*'
highlight BlankLine ctermbg=NONE ctermfg=NONE cterm=underline,bold
"highlight BlankLine cterm=underline,bold

e.g. for the code below Snapshot of code showing normal highlight, desired highlight and actual highlight

  • You are talking about which syntax rules have priority? Have you read :h syn-priority?
    – B Layer
    Commented Mar 3, 2021 at 19:22
  • I am looking for "merging" syntax rules rather than applying one out of many e.g. if I have ``` def function_name(): ``` I want the 'def' keyword to have its highlight(fg=yellow in my case) defined in the python syntaxfile + I want the line to be bold and underlined as defined above. Commented Mar 3, 2021 at 19:45
  • 1
    Syntax items do not "merge". They do "contain", "extend" and "overlap" each other. You have to stick to :match, matchadd() and such.
    – Matt
    Commented Mar 3, 2021 at 19:56
  • Ah, that's what you mean by "preserve color" then, I guess.
    – B Layer
    Commented Mar 3, 2021 at 20:34
  • Welcome to Vi and Vim! It might be helpful if you edit and include some examples of what you're trying to accomplish and what's not working
    – D. Ben Knoble
    Commented Mar 3, 2021 at 20:54

1 Answer 1


Different Syntax matches never combine highlighting. There's always one that wins, see :h :syn-priority, :h :syn-contains etc.

You need :h :match instead:

hi VSpace cterm=standout gui=standout
match VSpace /^\s*\n.*/

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.