Word wrap without line breaks
From Vim Tips Wiki
Tip 989 Previous Next Created: September 9, 2005 Complexity: basic Author: Pandora Version: 6.0
When editing a text file, if you want word wrapping, but only want line breaks inserted when you explicitly press the Enter key:
:set formatoptions=l :set lbr
lbr tells Vim to word wrap visually, but formatoptions=l tells Vim to not insert hard newlines when you edit the middle of a 'paragraph'. This is almost exactly the behavior of Notepad. Be sure to set formatoptions in your vimrc after setting compatibility options, or even near the end of your vimrc. Check with
:set formatoptions
to make sure it didn't get reset to something like formatoptions=tcq. =l is what you're going to want. And lbr to do word wrapping.
To make settings permanent, without the need to type this every time you use VI, just add the following line to your ~/.vimrc :
set wrap
The next time you use VI it won't add an extra line to the bottom of the file and you'll only add lines with the "Enter" key.
[edit] Comments
I think 'set wrap' does the same in one command.
The above commands are in addition to :set wrap in order to provide formatting. By default that will only wrap on characters, not words.
