This tutorial shows multiple examples to remove duplicate lines in Sublime text
Let’s have a first.txt file opened in a sublime text editor.
Eric
Andrew
Eric
John
Matt
John
One way is, to hover a line and select a text, manually removing the duplicate lines.
It is easy for files of small sizes. However, It is a very tedious task for a larger file that contains many lines of text.
How to remove duplicate rows in Sublime Text
- Open text file that you want to remove duplicate rows
- Select
Edit
>Permute Lines
>Unique
- It removes the duplicate lines and the output is as follows This option also removes duplicate line spaces if exists
Eric
Andrew
John
Matt
Permute Lines
has the following options
Unique
: delete the duplicate lines
Shuffle
: Shuffle the lines in the file
Reverse
: Reverse the lines, the first line becomes the last line and the last line becomes the first line
Order of lines keep the same order and does not sort with this option.
If you want to sort the lines and delete duplicates
- Select Edit > Sort Lines( use F9 shortcut)
- Next, Select
Edit
>Permute Lines
>Unique
- It sorts the lines and remove the duplicate lines
How to copy duplicate text in Sublime text editor
Select the line you want to duplicate line by hovering a text, Run below short cut command.
- Ctrl + Shift + D in windows
- Cmd + Shift + D in MacOS