Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Remove lines

    Help wanted · · · – – – · · ·
    5
    7
    734
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • iCrack
      iCrack last edited by

      Hello, i need help with removing lines for example i have 2 text files and i want to remove lines that already exist in file 2 from file 1. it should look like this
      file 1 lines
      awd
      awda
      awdd
      awddd
      awdddd
      awddddd

      file 2 lines
      awd
      awda
      awdd
      and after removing it should look like this
      awddd
      awdddd
      awddddd

      Eko palypse 1 Reply Last reply Reply Quote 0
      • Eko palypse
        Eko palypse @iCrack last edited by

        @iCrack

        if you have or don’t bother installing python script plugin then a script like this might do what you want
        Open File 1 and 2 and move file 2 into the other view(right click on tab and select Move to Other View)

        e1 = editor1.getCharacterPointer().splitlines()
        e2 = editor2.getCharacterPointer().splitlines()
        new_content = []
        for line in e1:
            if line in e2:
                continue
            new_content.append(line)
        editor1.beginUndoAction()
        editor1.setText('\r\n'.join(new_content))
        editor1.endUndoAction()
        
        Meta Chuh Alan Kilborn 2 Replies Last reply Reply Quote 4
        • guy038
          guy038 last edited by guy038

          Hello, @icrack, @eko-palypse and All,

          @icrack, it has been already discussed many times ! Just refer, for instance, to the link, below, if you prefer a built-in solution, without any plugin needed :

          https://notepad-plus-plus.org/community/topic/16335/multiline-replace-multiple-hosts-in-hostsfile/4

          Best Regards,

          guy038

          1 Reply Last reply Reply Quote 3
          • Meta Chuh
            Meta Chuh @Eko palypse last edited by

            @Eko-palypse

            don’t forget how difficult it can be to guide people to a manual pythonscript install nowadays.

            even after peter’s and my multiple step by step guides for installed and portable versions (which i currently just copy and paste repeatedly for the respective versions) many people still download eg. the msi or from a different source than the 1.3.0.0 of the guides, don’t get it to work, reinstall notepad++ completely with a different version and/or architecture, and repost after that, so that sometimes we had to start guiding from zero again.

            1 Reply Last reply Reply Quote 2
            • Alan Kilborn
              Alan Kilborn @Eko palypse last edited by

              I like Eko’s solution because since it doesn’t use regex, we can’t have a regex “screwup” (i.e., all text becoming selected in a file). :)

              Meta Chuh 1 Reply Last reply Reply Quote 3
              • Meta Chuh
                Meta Chuh @Alan Kilborn last edited by Meta Chuh

                @Alan-Kilborn

                i second that, i like it too.

                a few weeks ago i thought installing pythonscript is easy to install for anyone anyways, even on 7.6-7.6.3.
                but recent events, where people were given a step by step guide, and then answered that they did something completely different, probably because it was written to do so at the developers installation guide, and nothing works, made me re-think that a bit for now.

                currently i have this “self fulfilling prophecy” state of mind, when it comes to guiding standard users with a pythonscript plugin install, but i hope that goes away as soon as there are at least one or two users that actually managed to get it running at the first try 😉

                Alan Kilborn 1 Reply Last reply Reply Quote 2
                • Alan Kilborn
                  Alan Kilborn @Meta Chuh last edited by

                  @Meta-Chuh

                  You tell people to do something, then they do something completely different? Hmmm, I think I would quit trying. I’ve already got my own little children to raise up!

                  1 Reply Last reply Reply Quote 3
                  • First post
                    Last post
                  Copyright © 2014 NodeBB Forums | Contributors