TIP: Find & replace extra carriage returns (newlines) in Google Docs

Decorative image of old-fashioned typewriter.

Google Docs is handy to use especially for collaborations, but its inability to find and replace extra carriage returns or newlines is a pain. Here’s a workaround.

Some organizations I work with use Google Docs. I love how easy it is to use and to collaborate with others. However, one thing that I constantly need to do and couldn’t in Docs was to get rid of extra carriage returns or newlines using find & replace.

Thankfully, a member of an editors’ forum was able to show me how to do it. I’m jotting it down here as I’m sure others face the same problem!

The scenario

The writer used two carriage returns or newlines;1 I’d like to change that to one carriage return/newline.

A Google Doc with two newlines between paragraphs
An example Google Doc with two newlines (indicated by the pink P’s) between each paragraph.

The workaround

1. In your Doc, open Find & Replace

2. Tick the ‘Match using regular expressions’

A screenshot of a Google Doc's Find and Replace window. Put \n(?=\n) in the Find box, leave the Replace with box empty. Tick the box for 'Match using regular expressions'.

3. In the ‘Find’ box, type the following:

\n(?=\n)

4. Leave the ‘Replace with’ box blank and hit either ‘Replace’ or ‘Replace all’.

And voila! The double newlines are now single.

Google Doc example with single newlines between paragraphs.
The doubled newlines have been replaced with a single newline.

Often, I have to copy & paste the text to a website/blog interface, so not having to manually delete the extra newlines saves me a lot of time. (To improve readability in Docs in the meantime, I usually change the paragraph line spacing.)

I don’t understand the code so I’m afraid I can’t explain what the code actually means, but I’m grateful to my colleague for teaching me this!

In Word

In case you’re wondering, this is a lot easier to do in Word.

1. Open ‘Replace

2. In the ‘Find’ and ‘Replace’ boxes, put the following (the parts in bold):

'Find what' box: ^p^p
'Replace with' box: ^p

The ‘p’ should be lowercase; I’ve tried it with an uppercase ‘P’ before and it didn’t work.

Screenshot of Find and Replace window in Word. In 'Find what', put ^p^p and in 'Replace with', put ^p.

Note that in Word, you can have either paragraph breaks or line breaks (if you turn on hidden characters, the paragraph breaks appear as the backwards P and the line break as a little bent arrow).

Screenshot from Word showing that, if the hidden characters are displayed, a line break appears as a bent arrow and the paragraph break as a backwards P.
In Word, if you show the hidden characters, a line break appears as a bent arrow and the paragraph break as a backwards P.

If your document has line breaks (which it may if you’ve copied text from a web page, for example), then instead of ^p, use lowercase l (letter L):

'Find what' box: ^l^l
'Replace with' box: ^l

(Or you can replace them with a paragraph break, in which case, in the ‘Replace with’ box, you’d type ^p. In Word, I personally find it easier to work with paragraph breaks.)

Hope that helps!

Need help with your scholarly writing project? Let’s discuss! Please contact me with your requirements via the contact form or email me at info@theclarityeditor.com.

Cover image by Pexels from Pixabay 

Footnotes

  1. As a non-techie, I understand only that both are ways to code a move to the next line. Here’s a Wikipedia article on carriage returns (it links also to the newline article) and another slightly more technical explanation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.