History
Article Edit this page Discussion

Word wrap without line breaks

From Vim Tips Wiki

(Redirected from VimTip989)
Jump to: navigation, search

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.


Rate this article:

Share this article:

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto
Doctor Who
Legend of Zelda Wiki
Terminator Wiki
Everquest II Wiki
Mystery Science Theater 3000
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions
Send this article to a friend
"Word wrap without line breaks"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation