Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple highlight with autocmd in vimrc

Tags:

vim

vi

I would like to use two autocmd, to highlight lines too long, and to highlight spaces at the end of lines, but I don't succeed, only the last of the two commands is displayed... Is it possible ?

Here is the lines concerned:

augroup vimrc_autocmds
    autocmd BufEnter * highlight OverLength ctermbg=darkgrey guibg=#592929
    autocmd BufEnter * match OverLength /\%81v.*/
    autocmd BufEnter * highlight UnwantedSpaces ctermbg=red guibg=#red
    autocmd BufEnter * match UnwantedSpaces /\s\+$/
augroup END
like image 842
user2671415 Avatar asked Mar 13 '26 16:03

user2671415


1 Answers

You can only use one match at a time. If you want to use multiple you can use 2match and 3match. You only have three of these to use simultaneously without defining syntax highlighting for what you're trying to match.

like image 192
Randy Morris Avatar answered Mar 16 '26 23:03

Randy Morris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!