Sort, permute or remove duplicate lines in Sublime Text

Andrzej Wojciechowski

For years I have not noticed a built-in feature of my favorite code editor – Sublime Text. I have recently needed to deduplicate lines in a file and though I will need an additional package. And that’s when I discovered it’s an existing feature in default Sublime Text configuration. So particularly for my future reference, I decided to create this post.

How to remove duplicate lines in Sublime Text

Most of the posts here (but this one especially) are sort of notes-to-myself. You can remove the duplicate lines in Sublime Text using Permute Lines: Unique command. Both Sort Lines as well as Permute Lines are accessible via menu and the Command Palette.

Select from menu

The Sort Lines and Permute Lines options can be accessed from the Edit menu of Sublime Text. The two Sort Lines options by default have keyboard shortcuts assigned to them:

  • F5 for Sort Lines
  • Ctrl + F5 for Sort Lines (Case Sensitive)

The Permute Lines option contains submenu with 3 items:

  • Reverse to reverse the order of lines
  • Unique to remove duplicate lines
  • Shuffle to randomize the order of lines

Select from Command Palette

As you can guess, the same options available from the menu, can be accessed via the Command Palette as well. Simple keywords sort or permute are sufficient to find the commands.

References: