Is there a way to sort a list (single column, each item separated by \r
) in the buffer using just vim?
1 Answer
You can use the built-in sort utility:
:sort
Or pipe the buffer to an external Unix command:
:%!sort
For more info and options see :help :sort
and man sort
.
-
Neat I didn't know you could pipe the contents of a buffer to a command! Thanks man!– leeand00Commented Aug 21, 2015 at 16:33
-
1That's one of Vim's superpowers. If you use it, Unix is your IDE.– mrzoolCommented Aug 21, 2015 at 16:38
-
:sort
works on the whole buffer by default so you can leave out the%
.– romainlCommented Aug 22, 2015 at 14:33
help list-functions
.