Vim Tips Wiki

Automatic word wrapping

Revision as of 05:51, July 13, 2012 by JohnBot (Talk | contribs)

1,619pages on
this wiki
Tip 850 Printable Monobook Previous Next

created 2005 · complexity basic · author mmj · version 6.0

You can set the text width using :set textwidth=n (or :set tw=n) where n is a positive integer, for example:

:set tw=79

That will automatically wrap text as close to 79 characters as white space allows without exceeding the 79 character limit. This option wraps at word boundaries.

The textwidth option can be unset using:

:set tw=0

If you want to apply this to specific areas; bring the cursor at the beginning of the text you want to format and type gq. Now specify the range, say $ to format a large line.

:set wm=2

sets a wrap margin of 2 characters from the right window border. A system-dependent EOL character is inserted and the line wraps as you type. This option may be useful in some situations, but probably is not what you are looking for.



Around Wikia's network

Random Wiki