Problem

You use vim and you don’t want any lines to be longer than 80 characters. However, when you select a paragraph in the browser and you paste it in vim, the whole paragraph is inserted in one long line. Since you are just as lazy as me, you don’t want to break the line manually. What to do?

Solution

Select the line in visual mode ( Shift + V ). At the bottom you should see “ -- VISUAL LINE -- “. Press ! (now at the bottom you should see :'<,'>! ), type fmt (thus you have :'<,'>!fmt at the bottom) and press Enter . Done.

What just happened?

We passed the selected text to the external Unix command fmt , which reformatted the text. Vim then inserted the output of fmt to the place of the selected text.

So, if you have a list of words, one word in a line, and you want to sort them, just pass them to the external command sort : select the lines visually, !sort and Enter .

[ reddit discussion ]