Vim 7.3 brings the colorcolumn
option, as detailed very well in other answers.
However, if you don't have version 7.3 for whatever reason, you can still achieve a visual indication that you are exceeding a particular column count using vim's match
functionality (see :help match
for details).
Essentially, the match commands allow you to create persistent highlights for text matching a given regular expression. :match ColorColumn "\%80v."
will highlight text in column 80 with the "ColorColumn" group. You can of course substitute any highlight group, and any column value. If you want a strong visual indication, the expression "\%>79v.\+"
will highlight column 80 and beyond.
(\%80v
means "match in virtual column 80," and \%>79v
means "match after virtual column 79; see :help /\%c
for more.)
This approach will only highlight when there are actual characters present in the specified columns, however, which makes it visually less consistent than colorcolumn
.