Community
    • Login

    Add a line

    Scheduled Pinned Locked Moved General Discussion
    5 Posts 3 Posters 1.9k Views 2 Watching
    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 Offline
      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 Offline
        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 Offline
          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 Offline
            CJB @Terry R
            last edited by

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

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

              1 Reply Last reply Reply Quote 0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • First post
                Last post
              The Community of users of the Notepad++ text editor.
              Powered by NodeBB | Contributors