Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Does anyone know how to delete a line using Find & Replace in Notepad++ ?

In my Find query it finds the proper lines okay: ^.pPrev.$ In the Replace field, I leave it blank thinking the line should deleted (i.e. replaced with nothing), but the newline and endline characters remain.

share|improve this question
add comment

migrated from stackoverflow.com Jul 14 '11 at 6:37

This question came from our site for professional and enthusiast programmers.

5 Answers

up vote 8 down vote accepted

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.

share|improve this answer
1  
Does not work anymore in later Notepad++ versions (5.9.2 UNICODE tested) –  dtech Jul 10 '11 at 17:57
    
It seems like they keep pulling good features from Notepad++. First, the FunctionList plugin and now this. :( –  Jim Fell Oct 18 '11 at 16:48
    
still working. If not, delete \n first and then delete \r –  Jim Thio Jan 28 '13 at 8:16
    
I came here looking for info on how to remove line breaks and \r\n worked for me like a charm. Thanks! –  mabho May 1 '13 at 5:16
add comment

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.

share|improve this answer
add comment

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.

share|improve this answer
    
I'm not able to use \r or \n in RegEx mode (version 5.8.6). They only work in Extended mode for me. –  Justin Mar 21 '11 at 18:00
add comment

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.

share|improve this answer
add comment

Using Regular expression: find \xd\xa and replace what you want

if want to delete line breakes , leave the replace form blank.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.