Is there a way to sort a list (single column, each item separated by \r) in the buffer using just vim?

  • @Nobe4, really? help list-functions.
    – romainl
    Aug 22, 2015 at 14:31

1 Answer 1


You can use the built-in sort utility:


Or pipe the buffer to an external Unix command:


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!
    – leeand00
    Aug 21, 2015 at 16:33
  • 1
    That's one of Vim's superpowers. If you use it, Unix is your IDE.
    – mrzool
    Aug 21, 2015 at 16:38
  • :sort works on the whole buffer by default so you can leave out the %.
    – romainl
    Aug 22, 2015 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.