Community
    • Login

    Add a line

    Scheduled Pinned Locked Moved General Discussion
    5 Posts 3 Posters 683 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.
    • CJBC
      CJB
      last edited by

      I want to add a line after a specific line multiple times in a block of code. For example: I want to add “The color Red” after " The color Blue" where “The color Blue” line is in the block a hundred times.

      Terry RT PeterJonesP 2 Replies Last reply Reply Quote 0
      • Terry RT
        Terry R @CJB
        last edited by

        @cjb said in Add a line:

        I want to add a line after a specific line multiple times in a block of code

        I find the question ambiguous.

        Do you want to find a specific line which exists multiple times throughout a file, then add a single line after each instance? And the might be a hundred of the instances.
        OR
        Do you want to add a specific line 100 times after each time another line exists?

        Terry

        CJBC 1 Reply Last reply Reply Quote 0
        • PeterJonesP
          PeterJones @CJB
          last edited by PeterJones

          @cjb ,

          Use regular expression searching. Specifically,

          • FIND = The color Blue(\R)\K
            • (\R) will match your line ending and put it in group#1
            • the \K will reset the match “cursor” so that the replacement will go after the newline
          • REPLACE = The color Red${1}
            • the ${1} will put the contents of group#1 (your newline sequence) at the end of the new text
          • SEARCH MODE = Regular Expression
          • REPLACE ALL
            • cannot do one replacement at a time because of the \K

          ----

          Useful References

          • Please Read Before Posting
          • Template for Search/Replace Questions
          • FAQ: Where to find regular expressions (regex) documentation
          • Notepad++ Online User Manual: Searching/Regex
          CJBC 1 Reply Last reply Reply Quote 2
          • CJBC
            CJB @Terry R
            last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • CJBC
              CJB @PeterJones
              last edited by CJB

              @peterjones Perfect, thank you! Saved me sooo much time.

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