How to delete same lines in Notepad++?

1

I want to find out if there are any extra files between a long list of files that I generated. Because I`m weak at explaining stuff with words, I'd rather illustrate.

This is an illustration of the list of files that I have inside a Notepad++ session at the moment: (numerals represent line count)

1   gold.txt
2   silver.txt
3   copper.txt
4
5
6   gold.txt
7   silver.txt
8   copper.txt
9   unknown.txt

And the following is what I'm trying to achieve:

1
2
3
4
5
6
7
8
9   unknown.txt

How to remove everything with an exception of unknown.txt?

computationalprince

Posted 2018-11-28T00:50:18.443

Reputation: 101

1

Possible duplicate of Notepad delete duplicate lines

– Toto – 2018-11-28T08:39:41.427

@Toto It isn't. – computationalprince – 2018-11-28T09:50:09.297

Answers

2

Select menu Edit > Line Operations > Sort Lines Lexicographically Ascending to sort your file. Then press Ctrl+H to replace the texts like below

  • Find what: ^(.*?\R)(\1)+
  • Replace with: empty
  • Search mode: regular expression, with the option . matches newline unchecked

Then press replace all

Notepad++ sort lines

This will not leave the unknown.txt at the 9th line as your example, but it works

A better solution would be using the TextFX plugin. Just select TextFX > Click TextFX Tools > Check +Sort outputs only UNIQUE (at column) lines then remove the duplicates by selecting TextFX > TextFX Tools > Sort lines case insensitive (at column)

TextFX sort lines

phuclv

Posted 2018-11-28T00:50:18.443

Reputation: 14 930