Last Updated: September 26, 2017
·
2.603K
· bchretien

Vim: sorting a block of text

For Vim beginners, here's how you can easily sort a block of text:

<a href="http://i.imgur.com/pa0eOGG.gif" target="_blank">sort</a>

Details

vip: visual-select the inner paragraph

:sort: sort the selected text. This will default to alphabetical order. Note that after selecting the text and typing :, your command will be prefixed by :'<,'>. This part is related to the selection. If you simply run the :sort command (without the prefix), the whole file will be sorted.