Wikia

Vim Tips Wiki

Automatic word wrapping

Talk0
1,610pages on
this wiki
Revision as of 01:02, February 8, 2013 by 158.145.240.100 (Talk)

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.

Use

gq

on a line or paragraph that is too long, and vim will wrap it automatically at your assigned textwidth.

References

Comments

Advertisement | Your ad here

Around Wikia's network

Random Wiki