Community
    • Login

    Search multiple lines, and replace... with other multiple lines!

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    4 Posts 2 Posters 4.4k 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.
    • Julien MarchantJ
      Julien Marchant
      last edited by

      Dear notepad++ community,

      If you could help, I would really be eternally grateful. I’m not sure whether it’s possible to perform this action… but I’ve tried for almost two days with non optimal solutions.

      What am I trying to do?

      I have a Json file that I’m trying to edit on Notepad++. This file is quite long, 36k lines of code.

      Within this file, there are several instances that I need to replace with other data; about 500+ lines.

      Basically:

      codecodecode
      codecodecode
      “title”: “Dragon ball”
      code code code
      “title”: “Sailor moon”
      code code code
      “title”: “Digimon”
      code code code


      What I need to do is replace those titles with another set of strings. Thing is, I can’t run a search and replace for each one of them… that would be doing it 500+ times…

      What I managed to do on npp, is to bookmark all the istances I want to replace; copy the lines to a new document… but little else… when I cut/remove the lines the whole code shifts up… and I wish it didn’t do that, because then I could maybe paste the values in the remaining gaps maybe?

      If you have an idea on how I could search and replace all those lines in one fell swoop, I would really be thankful! Even if it means using another software… although somehow I think npp is what I need!

      1 Reply Last reply Reply Quote 0
      • Patrick MooreP
        Patrick Moore
        last edited by

        Can you post an “after” example of your text so I can see how it would be altered? Thinking it should be easy enough to do with a macro…

        1 Reply Last reply Reply Quote 0
        • Julien MarchantJ
          Julien Marchant
          last edited by

          Here’s an example:

          Before:
          codecodecode
          codecodecode
          “title”: “Dragon ball”
          code code code
          “title”: “Sailor moon”
          code code code
          “title”: “Digimon”
          code code code

          After:
          codecodecode
          codecodecode
          “title”: “Death Note”
          code code code
          “title”: "One Piece”
          code code code
          “title”: “Django Unchained”
          code code code

          I hope this helps!

          1 Reply Last reply Reply Quote 0
          • Julien MarchantJ
            Julien Marchant
            last edited by

            Ok! Actually Patrick (thank you Patrick), gave me a great idea.

            I put all the new strings that I was going to substitute at the top of the JSON file.

            Then I ran a search of the “title”: string, and bookmarked each instance.

            Then I ran a macro that:

            Highlighted the first line of the document
            Copied the line.
            Deleted the line. (So the second one would jump up, and the data gets deleted as well)
            Press F2 (to jump to the bookmark)
            Highlight the line
            Paste the line
            Pressed CTRL + F2 (to unmark the line)
            Pressed CTRL + Home (to go back to the top of the file)

            Rinse and repeat!

            Thank you again Patrick for giving me this idea!

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            The Community of users of the Notepad++ text editor.
            Powered by NodeBB | Contributors