• Login
Community
  • Login

Add a new text

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
searchreplacefilter
8 Posts 2 Posters 1.5k 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.
  • A
    Alij2022
    last edited by Apr 1, 2022, 4:51 PM

    Hi,

    I wonder if it is possoble to add a new line of codd below another line. Well, let me explain, I have a menu on 34 pages, built in HTML. I am adding another link on the menu and I do not want to open each page to add. So, I am wondering if we can search a specific line and then add a line after it without replacing the other line.

    I am not replacing here but adding.

    Thanks

    A 1 Reply Last reply Apr 1, 2022, 4:55 PM Reply Quote 0
    • A
      Alan Kilborn @Alij2022
      last edited by Apr 1, 2022, 4:55 PM

      @alij2022

      Yes, you would use a Regular expression replacement to do something like this. The general method is to match some text and then replace it with itself plus a line-ending plus the new line of text you want to add, plus another line-ending. I most cases, the line-ending will be represented by \r\n in the replace box in Notepad++.

      A 1 Reply Last reply Apr 1, 2022, 6:14 PM Reply Quote 2
      • A
        Alij2022 @Alan Kilborn
        last edited by Apr 1, 2022, 6:14 PM

        @alan-kilborn said in Add a new text:

        \r\n

        i dont know if im doing right, as it is replacing the the first line and add the new line on another paragrapgh.

        A 1 Reply Last reply Apr 1, 2022, 6:16 PM Reply Quote 0
        • A
          Alan Kilborn @Alij2022
          last edited by Apr 1, 2022, 6:16 PM

          @alij2022 said in Add a new text:

          i dont know if im doing right, as it is replacing the the first line and add the new line on another paragrapgh.

          Well I’m sure we don’t know what you’re doing, unless you show us. Take care to read HERE to do it properly.

          A 1 Reply Last reply Apr 1, 2022, 6:21 PM Reply Quote 0
          • A
            Alij2022 @Alan Kilborn
            last edited by Apr 1, 2022, 6:21 PM

            @alan-kilborn

            Here I have this code on my doc:

            <a href="home.html">Home</a>
            

            I wan to add this below it on all pages at once:

            <a href="travel.html">Travel</a>
            

            On Search tab, I chose Replace, then in Find field I select the whole first line and in Replace field I add the second line, with “\r\n” at the beginning. I chose Regular Expression as search type.

            Result is, it is replacing the whole first line with the second line on a new line.

            A 1 Reply Last reply Apr 1, 2022, 6:31 PM Reply Quote 0
            • A
              Alan Kilborn @Alij2022
              last edited by Apr 1, 2022, 6:31 PM

              @alij2022

              The very basics of it would be:

              Find: <a href="home.html">Home</a>
              Replace: <a href="home.html">Home</a>\r\n<a href="travel.html">Travel</a>

              A 1 Reply Last reply Apr 1, 2022, 6:39 PM Reply Quote 2
              • A
                Alij2022 @Alan Kilborn
                last edited by Apr 1, 2022, 6:39 PM

                @alan-kilborn

                Thank that’s works. But is there a way to indent the line as well like making it appear on the same line as the first one, with indentation?

                A 1 Reply Last reply Apr 1, 2022, 6:44 PM Reply Quote 0
                • A
                  Alan Kilborn @Alij2022
                  last edited by Apr 1, 2022, 6:44 PM

                  @alij2022 said in Add a new text:

                  is there a way to indent the line as well like making it appear on the same line as the first one, with indentation?

                  Sure, you can add in some spaces or tabs after the \r\n; for a tab character you can use \t.

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