Vim Tip: Sort Lines Alphabetically

Have a list that you need to alphabetize quickly? Vim has you covered. There’s a handy :sort command (:help sort for optional arguments) that will do just what it says on the box. All you have to do is select the lines in visual mode (v), and run :sort.

vim :sort

What sort of arguments does it support? The most common are probably ! and i, which reverse the sort order and ignore case, respectively. It supports some more advanced pattern-matching stuff, but I haven’t had cause to experiment with it yet.