Vim: word wrap for documents
wrap
and linebreak
control the display of text, I think you'll find they don't actually insert newlines in the file. To get vim to insert newlines in the file as you type, set textwidth
to the desired width (e.g. 80).
That will still not automatically reflow subsequent lines when you insert more text. I usually do that manually with gq}
, but I just discovered that set formatoptions+=a
will tell vim to do it automatically. See the help for auto-format
.
The gq}
wraps a paragraph to textwidth
. Be sure to set tw=80
first. Many distros map that to Q. So you may also be able to also use Q}
instead.