Last Updated: February 25, 2016
·
3.094K
· jamestomasino

Highlight text longer than 80 columns in vim

Add the following to your .vimrc to highlight any text that extends past the 80 column mark with a subtle red background.

" Highlight past 80 columns
if has('gui_running')
    highlight OverLength guibg=#592929
    match OverLength /\%>80v.\+/
endif

It's configured to only run in GUI versions of vim since it's pretty annoying in a term. It's very useful to bind the setting to a toggle key for quick checks.

Original Source: http://stackoverflow.com/a/235970/1041926

1 Response
Add your response

If you're running Vim 7.3 (or better) you can use set colorcolumn=80 which draws the vertical bar at this column. It lets you easily see the desired text width.

To gracefully support older Vims, use:

if exists('&colorcolumn')
    set colorcolumn=80
endif

To change the color, use ColorColumn highlight group.

over 1 year ago ·