Herr Bischoff


Vim: How to Sort a List of Email Addresses by Domain Name

I didn’t know until today that Vim allows for regular expression sort patterns. While consulting :h sort, I came across it, tried it out and (once again) left impressed by the versatility of Vim.

:sort /@.*/ r

You can apply this to any use-case by adapting the regular expression. By default, the pattern match is for what to skip while sorting. The trailing r inverts this behavior and tells Vim to sort by expression match instead.