Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim custom syntax highlighting background only

I want to customize syntax highlighting in Vim (GUI version). There is an existing syntax file for my language. I want to add to that syntax highlighting a background colour to each line if that line starts with >. I figured out that I can basically achieve this by

:syntax match Output /^>.*$/

and adding

:hi Output guibg=LightBlue

to the colourscheme. The background of the text in these Output lines gets coloured then in light blue, but it overrides the foreground colour as well. So most of the syntax highlighting disappears. How can I keep the foreground syntax highlighting in these lines?

Also: Is there a way to extend the highlighting of the background to the end (right end of the screen) of these lines?

like image 702
rembremading Avatar asked Aug 11 '11 21:08

rembremading


1 Answers

Here is how to preserve the syntax, I'm matching lines starting with {

:hi Output guibg=LightBlue
:match Output '\%>0v{.*'

enter image description here

Edit: since you want the opposite you need

:match Output '^[^<].*$'

enter image description here

like image 181
Eric Fortis Avatar answered Nov 14 '22 18:11

Eric Fortis