How do I use the find and replace function in notepad to delete multiple blank lines in a text file?


6 Answers 6


Within notepad there is no way to use the Find and Replace and target blank lines. Consider Notepad++ and the regex search and replace.

You can use \r\n to find blank lines from text files made within Windows, \r for Mac and \n for Linux.

I believe a default install actually comes with TextFX to make your life even easier, it has an option to delete blank lines:

alt text

  • 3
    Sounds to me that the next option, "Delete Surplus Blank Lines" might be what's needed here? (The question asker is not too clear about that, but otherwise the question could read: "How to delete a single blank line, and repeat that multiple times".)
    – Arjan
    Sep 28, 2009 at 8:58
  • Good answer, but it might as well be noted that Mac OS X uses \n to terminate lines, not \r as classic did.
    – jtb
    Sep 30, 2009 at 5:04
  • Notepad++ has Edit→Line Operations→Remove Empty Lines , but it's very slow with a 600k line file. TextFX "Delete Blank Lines" seems much faster? But doesn't handle whitespace lines. Whereas Notepad++'s "Trim Trailing Space" seems faster than TextFX's?
    – endolith
    Apr 21, 2021 at 18:13

I think you can't do it in notepad; when I have such a problem, I open the text file with Word (any other word processor should go) and replace two consecutive paagraph marks with one of them. Repeat several times (until there is nothing more to replace) and you're done.

You should replace ^p^p

with ^p


since the original notepad is a real pita (and everyone else is suggesting their own fav anyway):

vim ftw with:


There is a AutoHotKey tooltip extension for the purpose.
But, you could also change to Notepad++ and get better control.


In Notepad++ V7.7.1, in the Edit Tab, in the subgroup "Line Operations" there's the option "Remove Empty Lines".

enter image description here


7 Step Excel Solution:

Objective: Filter out all rows with data, leaving only the blank rows and then delete those blank rows.

  1. Copy your text file (Ctrl-A to select all and Ctrl-C will copy it) and paste into MS Excel, cell A1
  2. Highlight all rows with data in it. (with the cursor in cell A1 press Ctrl-shift-end)
  3. With the data highlighted, click on the Data tab, then click on Filter. (Cell A1 now has a drop down box on it.)
  4. The first item in the drop down box is "Select All" (uncheck it)
  5. The last item in the drop down box is "Blanks" (check it) (The worksheet now looks blank, all your data is hidden except for the blank lines in your data. Look at the row numbers on the left. The first row in your data with a blank in it is now at the top of your spreadsheet. Let's say it is line 330. The next line could skip to say line 775, the next line in your data with a blank and so on.)
  6. Place your cursor in cell A330. Press Ctrl-Shift-End. Which will highlight all blank lines in your data.
  7. While keeping the cursor in the highlighted area, Right click and select delete row. (Now would be a good time to go back and put the check mark back in the "Select All" box.)
  • Why should one purchase Excel for that purpose?
    – harper
    Mar 6, 2015 at 6:36
  • 1
    Also, the question seems to be asking how to change line A, line B, blank line, blank line, line C, line D to line A, line B, blank line, line C, line D. Your answer deletes all blank lines, doesn't it? Mar 6, 2015 at 7:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy