Community
    • Login

    Add a new text

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    searchreplacefilter
    8 Posts 2 Posters 3.1k 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.
    • Alij2022A Offline
      Alij2022
      last edited by

      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

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

        @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++.

        Alij2022A 1 Reply Last reply Reply Quote 2
        • Alij2022A Offline
          Alij2022 @Alan Kilborn
          last edited by

          @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.

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

            @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.

            Alij2022A 1 Reply Last reply Reply Quote 0
            • Alij2022A Offline
              Alij2022 @Alan Kilborn
              last edited by

              @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.

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

                @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>

                Alij2022A 1 Reply Last reply Reply Quote 2
                • Alij2022A Offline
                  Alij2022 @Alan Kilborn
                  last edited by

                  @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?

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

                    @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

                    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