14.06.2014 Views

vim 101 hacks

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Buyer: xiujuan lu (luxiujuan@gmail.com)<br />

Transaction ID: 85W16630AD8515549<br />

Vim <strong>101</strong> Hacks<br />

www.thegeekstuff.com<br />

Hack 40. Sort File Content<br />

Starting from Vim version 7, a built in Vim sort command is available.<br />

Sort file content from Vim as shown below.<br />

:sort<br />

Sort part of the file content as shown below.<br />

• Go to visual mode by pressing v<br />

• Use arrow keys and select the lines that need to be sorted.<br />

• Press :, which will show :'!sort<br />

The following options are available for the :sort Vim command<br />

:sort option<br />

:sort<br />

Description<br />

Sort in ascending order<br />

:sort!<br />

Sort in descending order<br />

:sort i<br />

Ignore case while sorting<br />

:sort u<br />

Remove duplicate lines.<br />

U stands for unique.<br />

74

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!