3

I have the following setting in my .vimrc for highlight long lines (>79) for python files

augroup vimrc_autocmds
    autocmd!
    autocmd FileType python,rst highlight Excess ctermbg=DarkGrey  guibg=Black
    autocmd FileType python,rst match Excess /\%79v.*/
    autocmd FileType python,rst set nowrap
augroup END

By some reason Vim highlights also other files (like .robot). enter image description here

How can I fix this?

  • 1
    You might also try to add set cc=80 to ftplugin/python.vim and ftplugin/rst.vim. Much better than relying on autocmds. – Sato Katsura Sep 15 '16 at 13:56
5

According to :help :match, it Define a pattern to highlight in the current window.. Thus if you open any other buffer (file) on the same window it will also display the highlight.

You would be better off by extending the syntax highlight for some languages, as explained at Vim FAQ 24.11. "How do I add my own syntax extensions to the standard syntax files supplied with Vim?".

Another option is to use the autocmd events BufEnter to set the match and BufLeave to clear it.

In any case, you could avoid cluttering your vimrc by using ftplugins, as explained in here.

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.