Vim Tips Wiki
(Change <tt> to <code>, perhaps also minor tweak.)
(Change <tt> to <code>, perhaps also minor tweak.)
Line 12: Line 12:
 
|category2=Usage
 
|category2=Usage
 
}}
 
}}
You can set the text width using {{tt|1=:set textwidth=n}} (or {{tt|1=:set tw=n}}) where n is a positive integer, for example:
+
You can set the text width using <code>:set textwidth=n</code> (or <code>:set tw=n</code>) where n is a positive integer, for example:
 
<pre>
 
<pre>
 
:set tw=79
 
:set tw=79

Revision as of 12:32, 15 July 2012

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.

References

Comments