• Login
Community
  • Login

ADD A LINE AT THE END

Scheduled Pinned Locked Moved General Discussion
5 Posts 3 Posters 22.8k 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.
  • M
    Memole1990
    last edited by Mar 30, 2022, 10:40 AM

    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!

    A 1 Reply Last reply Mar 30, 2022, 11:28 AM Reply Quote 0
    • A
      Alan Kilborn @Memole1990
      last edited by Mar 30, 2022, 11:28 AM

      @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
      • G
        guy038
        last edited by guy038 Mar 30, 2022, 2:20 PM Mar 30, 2022, 11:42 AM

        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 !

        M 1 Reply Last reply Mar 30, 2022, 12:25 PM Reply Quote 2
        • M
          Memole1990 @guy038
          last edited by Mar 30, 2022, 12:25 PM

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

          1 Reply Last reply Reply Quote 0
          • G
            guy038
            last edited by guy038 Mar 30, 2022, 2:19 PM Mar 30, 2022, 2:17 PM

            Hi, @memytim19,

            Just look here for documentation

            BR

            guy038

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