


#Notepad++ remove duplicate lines how to#
This is the important part in this regex, a row is only matched (and removed), when there is exactly the same row following somewhere else in the file. The sort command is used to order the lines of a text file and uniq filters duplicate adjacent lines from a text file. This Tutorial Helps to How To Remove Duplicate Words or Lines In Notepad ++ TutorialRemoveDuplicateLinesRemoveDuplicateWordsNotepad++Thanks Friends For. To remove duplicate lines, select the text you want to delete duplicates from and go to Edit -> Find and Replace or press Ctrl+H. (?=.*^\1$) this is a positive lookahead assertion. Steps to remove duplicate lines in notepad++. \s+?^ this part matches all whitespace characters (newlines!) till the start of the next row => This removes the newlines after the matched row, so that no empty row is there after the replacement. The matched row is stored, because of the brackets around and accessible using \1 (.*?) matches any characters 0 or more times, but as few as possible (It matches exactly on row, this is needed because of the ". You need to check the options "Regular expression" and ". Use Line Operations Open file in Notepad++ Editor.

In this example, we have a list of data types used in a SQL Server table. No sorting is needed for that and the duplicate rows can be anywhere in the file! There are multiple ways you can remove the lines. Remove Duplicates, Remove Blank Lines, and Sort Data in One Operation. This leaves from all duplicate rows the last occurrence in the file. Since Notepad++ Version 6 you can use this regex in the search and replace dialogue: ^(.*?)$\s+?^(?=.*^\1$)Īnd replace with nothing.
