Find and replace double paragraph breaks & make paragraphs continuous

I need to record this in a macro, so cannot use alternative find and replace. I want to find (and replace) double paragraph marks, and triple as well if possible, to remove large amounts of empty space in a document.

Then I can replace single paragraph marks with a single space to make the remaining paragraphs continuous text.

When I search for “$$” or “$$$” it does not work. Is there another approach?

EDIT: OK, there is no need for macros or RegExp. Go to Tools → AutoCorrect → AutoCorrect Options → Options tab and activate the option Remove blank paragraphs (also, deactivate anything you don’t want), now go to Tools → AutoCorrect → Apply and the empty paragraph will be removed.

I even wrote about this a few months ago… my memory is no longer what it used to be…


If there are no spaces on those empty paragraph, you can search for

^$

and replace with nothing. If there are spaces (any type, including tab stops), you need to first delete those spaces by searching for

^\s*$

and replacing by nothing, and then perform the first action to delete those empty lines.

Thanks, I did not know about this option. However, it has a couple drawbacks.

(a) Afterwards you have to turn all the options you want back on again, and then repeat these steps every time you want to apply to a document, whereas if you create a macro as per my chosen solution below you can just apply it quickly any time.

(b) And I still have the challenge of joining paragraphs that are broken up, as in my solution example below. This still requires me to find the double paragraph marks, the ones I will want to keep for real paragraph separation, and replace them with something like “paragraph2” as in my solution, then replace the single paragraph marks with space to join the text paragraphs into continuous text, then change “paragraph2” back to two paragraph marks.

Here is the solution I choose. It also addresses my larger problem, that I have line breaks in paragraphs when I want continuous text.

That is, I want to turn the following:

<===== START EXAMPLE =====>

Some text followed by four paragraph marks that should only be two.
   
   
   
A paragraph
with paragraph marks
that should be continuous.

<===== END EXAMPLE =====>

Into this:

<===== START EXAMPLE =====>

Some text followed by three paragraph marks that should only be two.

A paragraph with paragraph breaks that should be continuous.

<===== END EXAMPLE =====>

Steps to the solution, using regular find and replace:

  1. Replace all “$” with “paragraph1”.

  2. Replace all “paragraph1paragraph1paragraph1paragraph1” with “paragraph4”.

  3. Replace all “paragraph1paragraph1paragraph1” with “paragraph3”.

  4. Replace all “paragraph1paragraph1” with “paragraph2”.

  5. Replace all “paragraph1” with " " (i.e. a space).

  6. Replace all “paragraph4” with “\n\n”.

  7. Replace all “paragraph3” with “\n\n”.

  8. Replace all “paragraph2” with “\n\n”.

This is recordable by macro using regular find and replace.

Always a way!

See this question: writer:remove paragraph breaks at end of line containing characters