0

This SO post describes how to highlight all characters on a line in VIM past a given line number (80, in this case).

I'd like to have two sets of highlighted characters, columns 81-100 highlighted with one background color, and columns 101+ with another background color.

Here's what I've tried so far:

" Light highlight characters past column 80.  Red highlight past 100.
highlight OverLength1 ctermbg=red ctermfg=white guibg=#5b4f62
match OverLength1 /\%81v.\+/
highlight OverLength2 ctermbg=red ctermfg=white guibg=#990500
match OverLength2 /\%101v.\+/

as well as this variation on the 3rd line:

match OverLength1 /\%81v.\+($|100v)/

Neither works. The best I can get is to match 101+ alone; it seems like the second match overwrites the first match.

I don't like the colorcolumn option, I don't want to highlight empty columns, just text in the ranges specified.

Community
  • 1
  • 1
cydonian
  • 1,301
  • 10
  • 19

1 Answers1

1

Try

" Light highlight characters past column 80.  Red highlight past 100.
highlight OverLength1 ctermbg=red ctermfg=white guibg=#5b4f62
match OverLength1 /\%81v.\+/
highlight OverLength2 ctermbg=red ctermfg=white guibg=#990500
2match OverLength2 /\%101v.\+/

Read more about it on :h 2match.

ryuichiro
  • 3,557
  • 1
  • 12
  • 19