Search code examples
pythonvim

Vim: Highlight a Single Character at Column 80


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?


Solution

  • 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).