Remove blank lines but keep page breaks

I’ve been using the regular expression ^$ to find and remove blank lines from Libreoffice Writer documents, but I’ve found this also removes manual page breaks. Is there a way to remove blank lines but keep the page breaks?

Edit: What I am doing is using copy and paste to append text from another source to the end of an existing Libreoffice document which contains manual page breaks between headings. The appended text contains blank lines between paragraphs which I want to remove (for consistency with the existing text) without losing the page breaks from the original document. I am using Linux Mint 22.1 and Libre Office 24.2.7.2.

It has just occurred to me that the easiest solution is probably to paste the new text into a separate Libroffice document, remove the blank lines there (provided it has no manual page breaks of its own), and then re-copy it into the other document. But if anyone knows a more direct way to do it I would be glad to hear it.

Page breaks are text flow attributes of paragraphs (break before or after paragraph).

Empty paragraphs in a document don’t make sense because they contain no information.

Your non-empty paragraphs have a definite significance (or value) such as heading, narrative, note, … These significances are notified to Writer by applying a dedicated (paragraph) style. When the significance requires a page break, you configure this break in the paragraph style.

This method (I call it semantic styling) requires a change of mind about text formatting. In the end it is much more reliable and avoids the type of problem you met because there is no way to transfer a page break from one paragraph to another.

1 Like

imagen

1 Like

… the eventual extension is AltSearch https://extensions.libreoffice.org/en/extensions/show/70066

however, would need 3 passes :

  • replace “\m” by “WHATEVERMARK
  • replace “\p+” by nothing
  • replace “WHATEVERMARK” by “\m”