Removing duplicate rows in Notepad++

2019-01-01 16:32发布

Is it possible to remove duplicated rows in Notepad++, leaving only a single occurrence of a line?

标签: notepad++
10条回答
明月照影归
2楼-- · 2019-01-01 17:06

if the rows are immediately after each other then you can use a regex replace

Search Pattern: ^(.*\r?\n)(\1)+

Replace with: \1

查看更多
琉璃瓶的回忆
3楼-- · 2019-01-01 17:08

If you don't care about row order (which I don't think you do), then you can use a Linux/FreeBSD/Mac OS X/Cygwin box and do:

$ cat yourfile | sort | uniq > yourfile_nodups

Then open the file again in Notepad++.

查看更多
琉璃瓶的回忆
4楼-- · 2019-01-01 17:11

You may need a plugin to do this. You can try the command line cc.ddl(delete duplicate lines) of ConyEdit. It is a cross-editor plugin for the text editors, including Notepad++.

With ConyEdit running in background, follow the steps below:

  1. enter the command line cc.ddl at the end of the text.
  2. copy the text and the command line.
  3. paste, then you will see what you want.

Example
enter image description here

查看更多
看风景的人
5楼-- · 2019-01-01 17:11

None worked for me.

A solution is:

Replace

^(.*)\s+(\r?\n\1\s+)+$

with

\1
查看更多
登录 后发表回答