After watching Damian Conway's talk, I added the following two lines to my .vimrc.

highlight ColorColumn ctermbg=magenta
call matchadd('ColorColumn', '\%81v', 100)

My objective is to get the 81st column to be highlighted whenever a line goes beyond 80 characters. Unfortunately, if I open a new file and type 80i-, then I get highlighting on the 81st column even though there is no character there.

If I manually delete the 80th character and type it again, I sometimes get highlighting on the 81st column and sometimes don't. When I have 80 characters, I'd prefer not to have the 81st column highlighted.

How can I achieve this behavior?

2 Answers 2


The solution I'm using nowadays is:

matchadd('ColorColumn', '\%81v\s*\zs\S', 100)

That version highlights the first non-space character after column 80, which I find more useful.


After digging around a bit on the internet, I found this page which achieves a similar effect but is more specific in the match.

The fix is to add a . after the v.

call matchadd('ColorColumn', '\%81v.', 100)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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