I would like vim to color "long" lines for me. Using 80 columns as an example, I would like to highlight lines that exceed that length. Here is roughly what I think the .vimrc file should contain, although it (1) doesn't work, and (2) uses Perl's regex syntax to illustrate my point, because I don't know Vim's well enough:
...
highlight Excess ctermbg=0
au Syntax * syn match Excess /.{80,}$/
...
This (in my mind at least) should mark lines that exceed 80 columns. What I would ideally like is the ability to color only the part of the line that exceeds 80 columns, so if a line is 85 columns, then the 81st through the 85th columns would be highlighted.
I'm sure Vim can do this, just not with me at the helm.
I have this in my vimrc.
I found it here: Vim 80 column layout concerns
You might want to adjust the colors to your preferences.
Since I do not like the Vim 7.3 column marker, I just use the highlight text after column 80... at least that is what I want 95% of the time.
For the other 5% of the time, I wrote this small extension to also have a quick way to disable the highlight:
https://gist.github.com/fgarcia/9704429#file-long_lines-vim
I use the following method:
(These match some git pre-commit hooks)
The second line should be of interrest to you.
This uses an autocommand to adjust the OverLength value to match your file type.
I needed the autocomand to work for me:
Also like the idea of using 75 if you are aiming at 80 columns in average.
Taken from:
http://blog.ezyang.com/2010/03/vim-textwidth/
Possible reason why it fails without
BufEnter
: highlight + match can only be used once. Multiple usage means that old ones are overridden. How to add multiple highlights