tags:

views:

106

answers:

1

I am using mvim. I have following lines in my vimrc .

"highlight text that goes over 80 columns
highlight OverLength ctermbg=red ctermfg=white guibg=#592929
match OverLength /\%81v.*/

Sometimes in my project I see the extra characters highlighted and sometimes I don't . I mean once vim is displaying extra characters then it will continue to display extra characters. However if I get out of vim and start vim instance it might not highlight extra characters. To fix that I type

match OverLength /\%81v.*/

I am puzzled by why it is happening. Is it possible that some plugin is messing with these settings?

+2  A: 

It's possible that a plugin is undoing it by setting its own match. It's also possible that you're creating a new window. match is per-window (not per-buffer, and not global) so it only applies to the window that was active when the match command was executed.

You can try creating an autocmd to set up the match on new windows:

au! WinEnter match OverLength /\%81v.*/

Note that this is not executed on the first window.

Laurence Gonsalves
You are right when I create a new tab in the existing window then I do not get the highlights. I did not notice that until you pointed out. Lemme try your suggestion.
Roger
I put in your code in vimrc file like this."highlight text that goes over 80 columnshighlight OverLength ctermbg=red ctermfg=white guibg=#592929match OverLength /\%81v.*/"http://stackoverflow.com/questions/1608385/mvim-highlighting-long-text-works-sporadicallyau! WinEnter match OverLength /\%81v.*/I still have the same problem. When I create a new tab then I do not see the highlights. I am using mac. I saw WinEnter and thought may be solution will work only on windows.
Roger
Ah, yeah, for tabs you need to use TabEnter.
Laurence Gonsalves
TabEnter did not do it. First tab is highlighted second one is not.
Roger