Notepad++ Delete Lines with Find & Replace
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
and get $2,000 discount on your first invoice
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Puzzle Island
--
Chapters
00:00 Notepad++ Delete Lines With Find &Amp; Replace
00:25 Answer 1 Score 0
00:41 Accepted Answer Score 17
01:07 Answer 3 Score 1
01:54 Answer 4 Score 1
02:13 Thank you
--
Full question
https://superuser.com/questions/310380/n...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#notepad++ #findandreplace #newlines
#avk47
ACCEPTED ANSWER
Score 17
Use the "Extended" setting in the Replace window (not "Regular expression": I'm sure there's a way to do it with Regular expression, but using "Extended" works fine).
Enter ".pPrev.\r\n
" in the "Find what" field, and leave the "Replace what" field blank. This will include the \r\n characters in the match and delete the whole line.
ANSWER 2
Score 1
The general principle whichever editor you're using is that you need to include the new line characters (\r\n
assuming Windows line endings) in your search so that they will be included in the replacement and thus removed.
In Notepad++ this is made a bit more confusing by the 2 different search and replace commands. See this Wiki page for details: Replacing Newlines in Notepad++
I only had an old version of Notepad++ to hand so had to use Extended Search (accessed via ^R), making sure Regular Expr was unticked and using ^M to insert the new line character into the Find field. However if you make sure you're using Notepad++ 4.9 or later you should be able to use \r
and \n
in the regexp mode.
ANSWER 3
Score 1
You can actually select the newline by moving your cursor from the end of one line to the beginning of the next:
first line(from here)
(to here)decond line
third line
Then press ctrl+h while the new line is selected, and replace with nothing. This will delete all the newlines.
ANSWER 4
Score 0
Not sure about Notepad++, but you can always do it with gVim. The command is like this:
%g/^.pPrev.$/d
You can download gVim here if you don't have it already.