DEV Community

Colin Bartlett
Colin Bartlett

Posted on • Originally published at vimtricks.substack.com

1

Sort Lists, with and without plugins

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!

Over on VimTricks, I have a screencast and more examples.

Image of Datadog

Master Mobile Monitoring for iOS Apps

Monitor your app’s health with real-time insights into crash-free rates, start times, and more. Optimize performance and prevent user churn by addressing critical issues like app hangs, and ANRs. Learn how to keep your iOS app running smoothly across all devices by downloading this eBook.

Get The eBook

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay