Soft wrap at 80 characters in Vim in window of arbitrary width

I don't have a solution to the soft wrap, but as for marking a column, as of Vim 7.3 (released 2010-08-15) :set colorcolumn=80 will highlight column 80. The color will depend on your syntax file.

See Vim 80 column layout concerns, :h colorcolumn.


Try this:

set columns=80
autocmd VimResized * if (&columns > 80) | set columns=80 | endif
set wrap
set linebreak
set showbreak=+++

You can remove the if (&columns > 80) | if you always want 80 columns.


You could

  • set a large minimum width for the line numbers column via :set numberwidth=6 and
  • then you could resize your window with :set columns=86 (or with the mouse) to the proper size.

If you edit a file with a million lines in it, you may have trouble, but that's unlikely. You're wasting 6 columns of screen real estate this way too. So there are still all kinds of problems.

You can highlight past the 80th column using :match like it says here and here.

Beyond that I can't see any way to do this. Seems like it'd be a nice feature though.


Have you tried 'linebreak'?

        *'linebreak'* *'lbr'* *'nolinebreak'* *'nolbr'*
  'linebreak' 'lbr' boolean (default off)
        local to window
        {not in Vi}
        {not available when compiled without the  |+linebreak|
        feature}
If on Vim will wrap long lines at a character in 'breakat' rather
than at the last character that fits on the screen.  Unlike
'wrapmargin' and 'textwidth', this does not insert <EOL>s in the file,
it only affects the way the file is displayed, not its contents.  The
value of 'showbreak' is used to put in front of wrapped lines.
This option is not used when the 'wrap' option is off or 'list' is on.
Note that <Tab> characters after an <EOL> are mostly not displayed
with the right amount of white space.

Tags:

Vim

Word Wrap