A common practice of software developers is to sort lists of things alphabetically. A predictable order makes navigating lists easier and adding new entries faster. When another order isn’t obvious, use alphabetic ordering.
For text editing use cases outside of software, such as data editing and note taking, alphabetical sorting can be even more valuable.
The sort-motion plugin can make doing this easy, where it is otherwise tedious and involved. From the README:
sort-motion has four different sorting modes:
- Linewise: sort a sequence of lines (require statements, gem lists, etc)
- Character: sort a comma separated list (argument lists, attribute lists, etc)
- Visual (linewise or normal): provided for continuity, similar to linewise
- Block Visual: By default behaves the same as the other visual modes. Optionally, you can provide a specific sort command which you might use to sort by a column (example: Vissort)
The mode I use the most is visual: Select a block of text and use gs to sort the selection linewise. And if you need to reselect the same visual selection again, there’s a trick for that!
Top comments (0)