Add a line
-
I want to add a line after a specific line multiple times in a block of code. For example: I want to add “The color Red” after " The color Blue" where “The color Blue” line is in the block a hundred times.
-
@cjb said in Add a line:
I want to add a line after a specific line multiple times in a block of code
I find the question ambiguous.
Do you want to find a specific line which exists multiple times throughout a file, then add a single line after each instance? And the might be a hundred of the instances.
OR
Do you want to add a specific line 100 times after each time another line exists?Terry
-
@cjb ,
Use regular expression searching. Specifically,
- FIND =
The color Blue(\R)\K(\R)will match your line ending and put it in group#1- the
\Kwill reset the match “cursor” so that the replacement will go after the newline
- REPLACE =
The color Red${1}- the
${1}will put the contents of group#1 (your newline sequence) at the end of the new text
- the
- SEARCH MODE = Regular Expression
- REPLACE ALL
- cannot do one replacement at a time because of the
\K
- cannot do one replacement at a time because of the
-—
Useful References
- FIND =
-
This post is deleted! -
@peterjones Perfect, thank you! Saved me sooo much time.
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