Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does defining new match in Vim remove the previously defined one?

To show trailing whitespace in Vim, I use the following:

highlight whitespaceEOL term=reverse ctermbg=Grey guibg=Grey
match whitespaceEOL /\s\+\(\%#\)\@!$/

When I use the following match for long lines, the first match is lost:

augroup longLines
    autocmd! filetype zsh,sh,python,vim,c,cpp :match ColorColumn /\%>80v.\+/
augroup END 

Why is that happening?

like image 961
JuanPablo Avatar asked Sep 02 '25 16:09

JuanPablo


1 Answers

:match only matches one pattern at a time. :2match and :3match exist for exactly this reason. Try this:

2match whitespaceEOL /\s\+$/
3match ColorColumn /\%>80v.\+/

Alternatively, you can implement this as syntax. Try this:

syntax match whitespaceEOL /\s\+$/
syntax match ColorColumn /\%>80v.\+/
like image 90
Johnsyweb Avatar answered Sep 04 '25 07:09

Johnsyweb