Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 3
    wow, did not know the -s option of cat - just a historic note, it is not in POSIX, but seems to be available in BSD and GNU cat. Commented May 7, 2011 at 20:40
  • 8
    Marking as 'winning' for the :%!cat -s. Learn something GNnew everyday! Commented May 7, 2011 at 20:43
  • 5
    I think you can also use \r instead of ^M like this: %s!\n\n\n\+!\r\r!g Commented May 28, 2017 at 22:32
  • I use a technique like this using the fmt command to do hard word wrapping on text and unexpand to convert spaces to tabs. Commented Feb 16, 2021 at 6:08