TIL: :sort in vim
Last updated: 2/5/2025
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 ito ignore case.
- :sort uto deduplicate the lines.
- :sort nor- :sort ffor 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/ rto sort based on pattern.