removing duplicate lines



  • Can someone add “remove duplicate lines” as a menu option function?

    TextFX plugin used to do this, but it seems was not updated to support 64 bit version of Notepad++.

    Also I see a lot of answers saying go use regular expressions, but this is a very common operation I have used a lot and it is huge pain to go figure out a valid regular expression for this every time.

    Seems like this has been requested more than once by others as well.

    Hopefully thanks in advance.



  • @Robert-Mundkowsky

    What I’ve done is to record a macro for the regular expression search and replace for this. That gets rid of the “huge pain” to dig up the regular expression each time. Perhaps you will find value in doing the same. It may never become a built-in command; the developers don’t seem to build in functionality that can be accomplished in other ways (regex search and replace, plug-in, etc).



  • Hello, Robert Mundkowsky and Scott,

    @scott-sumner

    Nevertheless, the Notepad2 editor, for instance, has features for keeping only unique or multiple lines, while doing sort !!

    ( Select some text, in Notepad2 and hit the ALT + O shorcut to open the sort dialog )


    @robert-mundkowsky

    Here are, below, two useful links, on how to realize such operations, with the help of the N++ regex and sort features :

    https://notepad-plus-plus.org/community/topic/12490/i-want-to-keep-only-unique-lines/2

    https://notepad-plus-plus.org/community/topic/12569/delete-duplicate-lines/7


    • The first one gives you two solutions ( WITH or WITHOUT change of the file’s content’s ) to ONLY keep :

      • All the unique lines

      • All the duplicate lines

      • The first item of all the duplicate lines

    • The second one gives you a method ( WITHOUT change of the natural order of the file’s contents ) to ONLY keep :

      • All the unique lines AND the last item of all the duplicate lines,

    I’m, still, studying these questions, presently ! I’ll, also, try to see if these operations could be easily inserted in macros !

    So, see you later, for some updates :-))

    Best Regards,

    guy038


Log in to reply