I am trying to set up rules to highlight both trailing whitespace and lines which are over a certain length by adding this to my .vimrc:

highlight ExtraWhitespace ctermbg=lightgray guibg=lightgray
match ExtraWhitespace /\s\+$/

highlight OverLength ctermbg=lightgray guibg=lightgray
match OverLength /\%>80v.\+/

However, it only seems to pick up whichever is last. I can't find a way to get them to both work simultaneously.

link|improve this question

50% accept rate
feedback

1 Answer

up vote 0 down vote accepted

One way:

highlight EWOL ctermbg=lightgray ctermfg=black guibg=lightgray guifg=black
match EWOL /\%>20v.\+\|\s\+$/

Another:

highlight ExtraWhitespace ctermbg=lightgray ctermfg=black guibg=lightgray guifg=black
match ExtraWhitespace /\s\+$/

highlight OverLength ctermbg=lightgray ctermfg=black guibg=lightgray guifg=black
2match OverLength /\%>80v.\+/

Also available: 3match. Up to three matches can be active at a time. Or you can use matchadd() to create matches without limit to the quantity.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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