« How to Get SFTP Perl support on Windows XP | Main | BootStrap: Twitter's New Web Library »

June 03, 2011

VIM: How to hard wrap long lines of text?

Today, I needed to clean up some documentation from an email and I wanted to hard wrap the paragraphs at line length of 50.  After searching a few posts, I found a succinct solution.

14.2. How do I format long lines in a file so that each 
      line contains less than 'n' characters?

You can set the 'textwidth' option to control the number of
characters that can be present in a line. For example, to 
set the maximum width of a line to 70 characters, you can 
use the following command:

    set textwidth=70

Now to break the long lines in a file to the length defined
by the 'textwidth' option, you can use

    :g/./normal gqq



 

Chris

Posted at 08:07 AM | Permalink

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d8341f85d553ef015432bd8207970c

Listed below are links to weblogs that reference VIM: How to hard wrap long lines of text?:

Comments

Post a comment