TIL: :sort in vim
Last updated: Sat May 20 2023
vim has a built-in sorting function. Specify a range or a visual selection and run :sort
in command mode to sort the given lines. You can also do things like:
:sort!
to invert the order.:sort i
to ignore case.:sort u
to deduplicate the lines.:sort n
or:sort f
for integer or float numeric sorting; in particular, these will sort by the first number on each line.:sort /pattern/
to ignore a pattern and:sort /pattern/ r
to sort based on pattern.