Productivity and technology tips to get you jacked!

Removing Extra Lines in MS Word

April 3rd, 2007 — Craig

When working on an MS Word document you’ll sometimes find that there are extraneous blank lines between paragraphs getting in the way. This happens frequently when text is pasted in from another source, such as an ASCII file or an e-mail, where it is common practice to hit enter twice between paragraphs (as opposed to indenting the first line of each paragraph). In a Word, however, those extra lines are not only unnecessary, but they are intrusive. The paragraph formatting options in Word allow for refined control of inter-paragraph spacing, paragraph indentation, and so on.

In the example shown above, we have Word automatically inserting a 6pt spacer above each paragraph plus a 3pt spacer below (for a total of 9pts between paragraphs, which is slightly shorter than a typical text line containing a 10pt font with room for dissenters). The problem is that Word will treat a blank line as an entire paragraph, so we actually end up with about 30pt worth of spacing between paragraphs. Not good.

If there’s only a handful of such blank lines, then it’s no problem to simply place the cursor on each blank line, one at a time, and hit the delete key. But what if these extraneous blank lines go on for 50 pages?

In Word, every paragraph ends with a special paragraph mark, and it turns out that you can perform a search-and-replace on these paragraph marks just as if they were regular text. Normally these paragraph marks are invisible, but you can make them appear by clicking on the button with the paragraph symbol (¶) in the toolbar. Click on the button a second time to render them invisible again. (Note: the paragraph symbols do not need to be visible in order to perform a search and replace against them. I just wanted to show you how to make them visible in case you were curious.)
In the search/replace dialog, the notation that refers to a paragraph symbol is ^p (the caret symbol, followed by a lower case P). Don’t worry if you can’t remember this code. Simply click on the More/Less button to expand the dialog box, then click on the special button, and select Paragraph Mark. It will automatically type the ^p for you (into either the Find What, or Replace With, whichever had focus last).

Now, here’s the tricky part. You might think that, in order to delete the blank lines, you’d want to set Find What to ^p, leave Replace With blank, and click the Replace All Button. That will certainly delete the paragraph marks on those blank lines, effectively removing the blank lines, but it will also delete the paragraph marks at the end of the legitimate paragraphs. So, you’d end up with your entire document being one huge paragraph.

Instead, set Find What to ^p^p, and set Replace With to ^p. This tells Word that anywhere it sees two paragraph marks together, with nothing in between them, to replace them with a single paragraph mark — which has the net effect of leaving the first paragraph mark alone while deleting the second one. Note that if your file has multiple blank lines between paragraphs, then you’ll have to click the Replace All button repeatedly to eventually collapse all of the blank lines to nothing.

Now, say instead that the source material did not have blank lines between paragraphs but did indent the first line of each paragraph by five spaces. Here again, those spaces would interfere with the paragraph formatting. To delete those leading spaces, open the search and replace dialog, set Find What to ^p followed by five spaces, and set Replace With to ^p. After clicking on the Replace All button, any paragraph that is followed by another paragraph where the first five characters are spaces, those spaces will be removed. (Note: This counts on you knowing that the paragraphs with leading spaces begin with exactly 5 spaces. If you are unsure of the number of spaces, or if the number varies, then just have this search and replace dialog find ^p followed by a single space (still replacing it with ^p alone). Then, keep clicking on the Replace All button repeatedly until Word reports that it made zero replacements.

It isn’t uncommon to want to change the formatting of your Word document after you’ve created it. Changing a document’s formatting in word is usually fairly easy. You simply select the text you’d like to change. Then you apply the new formatting.

But, you can run into complications. For example, you may not have used the formatting options to specify the spacing between paragraphs or lines of text. Instead, you may have inserted extra returns. Do you have to scroll through your document, removing the extra returns manually?

The process would be tedious. Fortunately, there is an alternative. You can use Word’s Find and Replace feature to remove the extra breaks.

Follow these steps:

1. Press Ctrl + H to open the Find and Replace dialog box

2. In the first box, enter ^p^p (the “p” must be lower case)

3. In the second box, enter ^p

4. Click Replace All

Note: This will replace two paragraph breaks with one. You can specify other options, depending on the number of paragraph breaks you’d like between paragraphs. You can also replace a paragraph break with another character, if you choose.

If you copied the text from the Internet, this might not work for you. That’s because there are different types of breaks in HTML files. Not to worry, there is a solution: