How can I Find/Replace multiple paragraph marks at the same time?
Specifically:
I have a document that has multiple empty (blank) lines.
If I Find/Replace using the expression ^$ Writer replaces every single blank line.
However, the document has content where there are 2 blank lines.
I would like to Find/Replace every instance that has 2 blank lines but leave the single blank lines as-is.
The expression ^$^$ does not work. Writer says it cannot find the expression (even though using ^$ works).
Also, using the expression \n^$ or ^n^$ or ^$^n or ^$\n does not work. Even though ^n (finds lines beginning with “n”) or \n (error “Search key not found”) does not work either.
As a workaround to replace two empty paragraphs with a single empty paragraph:
- find all empty paragraphs (
^$) and replace them with a non-used character (i.e., █) - find all █$ and replace with
""(none) - find all █, and replace with
\n
But it is better to use paragraph styles.
Built-in Edit → Search & Replace operates only on a single paragraph contents.
When you write ^$^$, you span two paragraphs which is out of specification for this built-in function.
As an alternative, you may try extension AltSearch.
Leaving empty paragraphs in a document is an error. Empty paragraphs contains no information; they should not exist (because a paragraph is a basic unit of information in Writer).
Using empty paragraphs for vertical spacing is also an error because edits may move page breaks and your empty paragraphs will also move, thus ruining your layout. The correct way of vertically spacing is to include this spacing in the paragraph configuration (usually through a style). You can define spacing both above and below paragraph. When a paragraph appears at top of page, spacing above is suppressed (unless you request otherwise) and spacing below is also suppressed at bottom of page. Defining spacing as a paragraph property gives you more (automatic) versatility than manually adding empty paragraphs.
Check this extension AltSearch, as it tells to handle regular expressions over multiple paragraphs:
Does this mean that Writer does not support the action of replacing multiple paragraph marks?
The link is an add-in. I do not, as a rule, trust add-in applications based on previous bad experiences.
Is there a way to accomplish the replacement within Writer?
Or, is this a deficiency in Writer that can only be addressed by add-in applications?
As already mentioned, built-in Find & Replace function is limited to edition(s) inside a single paragraph. This was a design decision. I am no developer but I assume it is related to internal representation of document where paragraphs are likely to be not related, at least in reading order.
The replacement itself, no. But you should restructure your document so that it contains no empty paragraphs. Empty paragraphs are evil. Sooner or later, they ruin your layout. For vertical spacing between paragraphs, adjust the Spacing above and below properties in paragraph styles.
Please check the comment by @LeroyG above.
It can’t be done in a single step, but in the described 3 steps.
Thank you to all for the replies.
I guess the work-around is the only option.
The problem, and the reason for this question, is not my creation of a document with empty/blank paragraphs.
It is the copy/paste of documentation from other sources (e.g. Internet, MS Word, Calc/Excel).
In many instances, during the “Paste” of the documentation, Writer creates empty/blank paragraphs.
Especially when the documentation is pasted as unformatted text.
Writer never adds data not already present in the source. Over all, don’t trust what you copy from the internet. It is coded as HTML. This format has its own constraints and idiosyncrasies which translate weird when pasted into Writer. Unformatted is the safest form, but it wipes out all formatting and you must reconstruct it.