Community
    • Login

    ADD A LINE AT THE END

    Scheduled Pinned Locked Moved General Discussion
    5 Posts 3 Posters 29.8k Views 1 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.
    • Memole1990M Offline
      Memole1990
      last edited by

      Hello, I am novice to NotePad.

      I would need to add a new line of text after certain lines already present (not all of them).

      I tried with:
      Find what: $
      Replace with: \r

      But in this way he adds a new line to me at the end of all the lines already present.

      How could I do that? Thank you very much!

      Alan KilbornA 1 Reply Last reply Reply Quote 0
      • Alan KilbornA Offline
        Alan Kilborn @Memole1990
        last edited by

        @memytim93

        Well you’d have to start by specifying how to identify these “certain lines already present”, i.e., what makes them special? There has to be a pattern to it otherwise it can’t be done.

        1 Reply Last reply Reply Quote 1
        • guy038G Offline
          guy038
          last edited by guy038

          Hello, @memytim19 and All,

          Well, it depends on the location where you want to insert this new line :

          • If you want to insert this new line at the very end of current file :

            • SEARCH \z

            • REPLACE \r\n

          • If you vant to insert this new line after the Nth first lines of current file

            • SEARCH (?-s)\A((?:.*\R){N})

            • REPLACE \1\r\n

          • If you want to insert this new line after the line ( or each line ) containing the named string String

            • SEARCH (?-s)(?<=String)(.*\R)

            • REPLACE \1\r\n


          For instance, given this INPUT text :

          This is a
          small example
          of text
          to test the
          regexes
          Hope this test will
          be OK
          

          The first regex S/R would produce :

          This is a
          small example
          of text
          to test the
          regexes
          Hope this test will
          be OK
          
          

          The regex S/R :

          • SEARCH (?-s)\A((?:.*\R){5})

          • REPLACE \1\r\n

          gives the following OUTPUT text :

          This is a
          small example
          of text
          to test the
          regexes
          
          Hope this test will
          be OK
          

          and, finally, the regex S/R :

          • SEARCH (?-s)(?<=test)(.*\R)

          • REPLACE \1\r\n

          would return :

          This is a
          small example
          of text
          to test the
          
          regexes
          Hope this test will
          
          be OK
          

          Best Regards,

          guy038

          P.S. :

          Of course, select the Regular expression search mode and tick the Wrap around option !

          Memole1990M 1 Reply Last reply Reply Quote 2
          • Memole1990M Offline
            Memole1990 @guy038
            last edited by

            @guy038 Thank you very much, it’s perfect, I still have a lot to learn

            1 Reply Last reply Reply Quote 0
            • guy038G Offline
              guy038
              last edited by guy038

              Hi, @memytim19,

              Just look here for documentation

              BR

              guy038

              1 Reply Last reply Reply Quote 1

              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