Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

Sort and Reverse Sort a Selection of Text or File in Vim

sort-and-reverse-sort-a-selection-of-text-or-file-in-vim.jpg

Sorting text is useful, such as sorting dependencies or package imports. Here's how to quickly do it with the built in sort command.

Quick Jump:

This is a 2 minute video going over how to sort (sort), reverse sort (sort!) and uniquely sort (sort u) text in Vim. You can also combine them together such as reverse unique sorting text with sort! u. You can apply this to a selection of text or the entire file.

# Demo Video

Timestamps

  • 0:08 – Sorting a selection of text using the built in sort command
  • 0:33 – Reverse sorting a list by adding a bang at the end
  • 0:54 – Sorting a unique selection of text
  • 1:09 – Combining reverse sort with removing duplicates
  • 1:24 – Sorting an entire file with the same sort command
  • 1:48 – Checking out sort’s help menu within Vim

Do you prefer Vim’s sort or shelling out to the sort command? Let me know below.

Never Miss a Tip, Trick or Tutorial

Like you, I'm super protective of my inbox, so don't worry about getting spammed. You can expect a few emails per year (at most), and you can 1-click unsubscribe at any time. See what else you'll get too.



Comments