Edit > Permute Lines > Unique
is great for removing duplicate from a list in Sublime Text. But what if I wanted to remove all matching results instead? For example:
james
james
bobby
mary
ann
ann
The above list of names would become:
bobby
mary
Because bobby
and mary
are the only names that only appear once.
Remove duplicates from list using Set. To remove the duplicates from a list, you can make use of the built-in function set(). The specialty of set() method is that it returns distinct elements.
If you don't mind your lines being sorted, you could do it like this:
(^.*$\n)\1+
Although, sorting wouldn't be necessary if all the duplicates are next to each other, as per your example. e.g. it would even work with the following:
james
james
bobby
mary
ann
ann
james
james
james
Note that this regex requires the last line to have a trailing newline character, if it is a duplicate, otherwise it won't find it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With