Last Updated: February 25, 2016
· 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.\+/

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:

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

To change the color, use ColorColumn highlight group.

over 1 year ago ·