Take the 2-minute tour ×

On this page, I've found this pattern


that helps in identifying lines longer than 80 characters by highlighting the characters after column 80.

I fail to understand its bit by bit explanation. Could you help me?

share|improve this question
Oh, you could also use this to match lines with at least 81 characters: /.\{81\}.*. I find this easy to remember. –  steffen Nov 1 '12 at 13:20
@steffen: Not exactly. A character does not necessarily occupy a single display cell (think <Tab> or Asian characters). The virtual column \%v matches cell width, your . atom characters. –  Ingo Karkat Nov 1 '12 at 13:26
add comment

2 Answers

up vote 2 down vote accepted

This is quite simple, actually.

  • \%>80v starts the match after the virtual column number 80, see :help %>.

  • .\+ matches 1 or more of any character, see :help /. and :help \+.

share|improve this answer
that was a nice explanation. does virtual column mean tab counts as single character instead of 8 cells as seen on page ? –  user1371666 Nov 15 '12 at 1:40
No. virtual columns count tabs as x characters. Assuming a tabwidth of 8 and a line consisting of <tab><tab>abc with the cursor on a: :echo col('.') returns 3 and :echo virtcol('.') returns 17. –  romainl Nov 15 '12 at 6:52
add comment

This is an alternative to your posed question rather than an answer. Hope that's ok.

You can also look into colorcolumn.

set colorcolumn=81,82,83

Will highlight the three characters after column 80. If you use textwidth then you can also use relative values (cool if your textwidth changes for different files):

set textwidth=80
set colorcolumn=+1,+2,+3

Of course you can have as few or as many values as you want separated by columns. I don't think it takes ranges though or "open sets" to "highlight from column N to the end of line."

The color itself is defined by the ColorColumn group so you can change it easily if it's too garish.

The reason why I suggest this is that it operates even if you're using search for finding things. :)

share|improve this answer
add comment

Your Answer


