Jeff Roberts
RHCE #804006066322833
Vim-Fu is now iPhone and Android friendly

Check out the Vim-Fu Store!

Vim-Fu

sorting in VIM

sorting in vim is simple.
a list of number like this:

3
30
423
21
3
9871

is easily sorted by typing “:sort” (every line in buffer) or “:%sort” (every line in buffer) or “1,5sort” (this last one only sorts lines 1 – 5)

resulting in:

21
3
3
30
423
9871

You can use the “-u” option while sorting to get rid of the duplicates, but you must also add the “!” (filter) option:

:%!sort -u

21
3
30
423

9871

The “%” means “all lines in buffer”

One last thing. You can use visual mode to highlight the bit that you want sorted and leave the rest alone.

CTRL-V and use the navigation keys h,j,k,l to select the text, then ESC and finally “:sort”

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>