Sublime Text 2 - remove duplicated words in a list of words

12,007

Solution 1

Ctrl G selects all occurrences of a pattern in the current file on a Mac in Sublime Text 2. So, in your example, dropping your cursor on any instance of Hey (not explicitly highlighting it) and invoking Ctrl G will select every instance of Hey in your file. You can then delete all of them in one go and re-add a single instance.

A few things to note on Ctrl G that might save you some headaches in the future. By default, it is case-insensitive. You can change this by invoking the global find and replace tool with F and toggling the case-sensitivity button. It should respect whichever option you leave it on for all subsequent searches.

Also, if you were to actually highlight an occurrence of Hey in your file and invoke Ctrl G, it would pattern match any sequence of characters containing those letters in that order — e.g., if they were in your file, the hey in it would be selected.

Solution 2

I see that I'm too late, but it's worth mentioning that sublime have command "Permute lines - Unique", which deletes duplicates from selected lines. Works like a charm, and there are answer on superuser about shortcuts: hotkey to remove duplicate lines in sublime

Solution 3

If you want a faster method, just select the whole text or list and go to Edit - Permute Lines - Unique. This will sort lines alphabetically and remove duplicated entries.

Another method is to sort your list alphabetically and search for duplicates manually.


See more details and live examples here:

http://html-tuts.com/remove-duplicate-lines-using-sublime-text/

Solution 4

You can select multiple regions of text and edit them all at once. On OS X highlight the desired word and press Cmd+D to select and go to the next occurrence or Cmd+K+D to skip and go to the next occurrence.

Sublime Text selections

Solution 5

Just:

Edit -> Sort Lines (F9)
Edit -> Permute Lines -> Unique
Share:
12,007
itsme
Author by

itsme

JS

Updated on June 14, 2022

Comments

  • itsme
    itsme almost 2 years

    Is there anyway to remove duplicates in a list of words like this?

    Hey
    Hello
    Hey
    Hey
    Jhon
    Mark
    Salcaz
    

    i'm on macosx and each word is on new line formatted 1 word per line