How to find text, then delete the next line?
-
How can I find text, then delete the next line? I know how to find the text, but how do I tell N++ to then delete the line following?
Or… find text, bookmark the line following?
Thanks… -
@Scott-DuBose said in How to find text, then delete the next line?:
How can I find text, then delete the next line?
You haven’t explained if you are finding text through a regular expression (regex) or just by searching for that exact text or manually.
The easiest method of removing a following line is through a regex. It will allow you to search using a search pattern, then remove the folowing line. Example is
line here line here this line is what i want to find this line I want to delete
Regex used would be similar to (using the Replace function):
Find What:^.*i want to find\R\K^.*\R
Replace with:empty field here
So the regex uses the first portion to find a line ending in “i want to find” followed by a carriage return/line feed. It then promptly discards that selection (using the \K) and then selects the complete line following and replaces it with
nothing
, so deleting it. If the following line is empty it will still work.Terry
-
This post is deleted! -
This post is deleted! -
Thanks, it worked! Example:
Message 34159
34158
2009-01-02 09:40:51I Find: Message.?\R\K^.\r
Which then selects 34158 on the second line.
When I enter nothing in the “Replace with” field, and clicked " Replace" - it did nothing. But when I clicked “Replace All,” it cleaned all the lines I wanted gone. Thanks for your help…
-
Why are asterisks being removed from my post? Regex used is
-
@Scott-DuBose said in How to find text, then delete the next line?:
Why are asterisks being removed from my post?
Because this forum uses a form of “markdown” and the asterisk is a character that has special meaning. It adds italics if you wrap a word with 2 asterisks.
The way to get it to NOT interfere with your text is to use backticks around your text; then what you type will appear like
this
and will not be messed with. -
Thanks, had to look up backtick… :-)
Found it!
-
Thanks, in a document with 124,000 lines, this deleted 20,000 lines in about 10 seconds. Notepad++ is so awesome.
Shoutout to Don Ho