vim command to restructure/force text to 80 columns

Posted by wickedchicken on Stack Overflow See other posts from Stack Overflow or by wickedchicken
Published on 2010-06-13T18:35:57Z Indexed on 2010/06/13 18:42 UTC
Read the original article Hit count: 338

Filed under:
|

I know there are ways to automatically set the width of text in vim using set textwidth (like http://stackoverflow.com/questions/235439/vim-80-column-layout-concerns). What I am looking for is something similar to = (the indent line command) but to wrap to 80. The use case is sometimes you edit text with textwidth and after joining lines or deleting/adding text it comes out poorly wrapped.

Ideally, this command would completely reorganize the lines I select and chop off long lines while adding to short ones. An example:

long line is long!
short

After running the command (assuming the wrap was 13 cols):

long line is
long! short

If this isn't possible with a true vim command, perhaps there is a command-line program which does this that I can pipe the input to?

© Stack Overflow or respective owner

Related posts about vim

Related posts about wordwrap