6

So, in good PEP fashion I am attempting to keep column width to below 80 for Python code. I have been using the colorcolumn=80 option in my .vimrc but in the terminal (I am not a fan of gvim or macvim) the effect of a fully black stripe down column 80 is too jarring for my taste. I also have no desire to enable wrapping as there are many cases where I need to go beyond the line.

I had read somewhere that someone set it to highlight only the single character at column n in a bright color and this sounds like a perfectly subtle visual cue.

Unfortunately for the life of me and despite my Googlefu I cannot locate how this was accomplished.

Any takers?

damienstanton
  • 409
  • 3
  • 5
  • 10
  • I guess making the column red would be a little more jarring, eh? ;) – Wayne Werner Apr 23 '14 at 14:12
  • Note that that duplicate question also has an alternative to ColorColumn, but also shows how you can set the color to be something less jarring. – Daniel Roseman Apr 23 '14 at 14:22
  • in another word, you want to HL the char on 80th col only if the char reaches that far? – Kent Apr 23 '14 at 14:43
  • 1
    Daniel, thanks for the link. It's not quite the same as what I'm looking for though because that deals with changing the highlighted background color (via colorcolumn or otherwise), while I'm looking to change the char color itself. Kent, you have it exactly; the goal is highlighting / changing the color of the char solely on col 80 – damienstanton Apr 23 '14 at 14:53
  • @DS_Scalar I wish I could upvote this like ten times! XD – Jeff B Apr 23 '14 at 15:56

2 Answers2

10
hi Bang ctermfg=red guifg=red
match Bang /\%>79v.*\%<81v/

this two lines will hi the char in 80th column, only if there is a char. The color I used is red, for example. you can pick other sexy colors (fg/bg).

Kent
  • 189,393
  • 32
  • 233
  • 301
8

You can keep using colorcolumn, with no background color and red foreground color:

:hi ColorColumn ctermbg=NONE ctermfg=red

Before:

before

After:

after

romainl
  • 186,200
  • 21
  • 280
  • 313