Add a new text
-
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
-
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++. -
@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.
-
@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.
-
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.
-
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>
-
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?
-
@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
.