• Login
Community
  • Login

Remove lines

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
7 Posts 5 Posters 1.0k Views
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.
  • I
    iCrack
    last edited by Feb 17, 2019, 1:47 PM

    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

    E 1 Reply Last reply Feb 17, 2019, 2:10 PM Reply Quote 0
    • E
      Eko palypse @iCrack
      last edited by Feb 17, 2019, 2:10 PM

      @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()
      
      M A 2 Replies Last reply Feb 17, 2019, 8:31 PM Reply Quote 4
      • G
        guy038
        last edited by guy038 Feb 17, 2019, 3:38 PM Feb 17, 2019, 3:37 PM

        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
        • M
          Meta Chuh moderator @Eko palypse
          last edited by Feb 17, 2019, 8:31 PM

          @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
          • A
            Alan Kilborn @Eko palypse
            last edited by Feb 18, 2019, 12:34 AM

            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). :)

            M 1 Reply Last reply Feb 18, 2019, 1:49 AM Reply Quote 3
            • M
              Meta Chuh moderator @Alan Kilborn
              last edited by Meta Chuh Feb 18, 2019, 2:27 AM Feb 18, 2019, 1:49 AM

              @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 😉

              A 1 Reply Last reply Feb 18, 2019, 1:33 PM Reply Quote 2
              • A
                Alan Kilborn @Meta Chuh
                last edited by Feb 18, 2019, 1:33 PM

                @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
                7 out of 7
                • First post
                  7/7
                  Last post
                The Community of users of the Notepad++ text editor.
                Powered by NodeBB | Contributors