0

I got these two autocmd config in my .vimrc

autocmd FileType python highlight OverLength ctermbg=red ctermfg=white guibg=red
autocmd FileType python match OverLength /\%80v.\+/
autocmd FileType python highlight ExtraWhitespace ctermbg=blue guibg=blue
autocmd FileType python match ExtraWhitespace /\s\+$/

The first one will show the part of line which is greater than 80 characters in red background color.
Meanwhile the second one will show extra white space at the end of line in blue.

The problem is, they can't working together!
If I enable both of them, only the second ExtraWhitespace works.
But if I commented out the ExtraWhitespace, OverLength starts to work right.

Why did this happened, how to fix it?

  • match only works once. It's not the same as a syntax match. – Joe Sewell Mar 17 '15 at 16:57
2

Use :2match for the second one (see :help :2match for details and also note that :3match is used for matchparen plugin):

autocmd FileType python highlight OverLength ctermbg=red ctermfg=white guibg=red
autocmd FileType python match OverLength /\%80v.\+/
autocmd FileType python highlight ExtraWhitespace ctermbg=blue guibg=blue
autocmd FileType python 2match ExtraWhitespace /\s\+$/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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