Ask Your Question

Is there a way to globally reduce the number of hard returns

asked 2017-01-19 12:04:12 +0100

MykeH gravatar image

for instance I download text stories and in some of these there are 3 or 4 or more hard returns between paragraphs. Is there a way to globally reduce these to 2 hard returns so there is only one blank line between paragraphs? Thank you for your time

edit retag flag offensive close merge delete

5 answers

Sort by » oldest newest most voted

answered 2017-01-19 12:31:40 +0100

Mike Kaganski gravatar image

updated 2017-01-19 12:32:53 +0100

I'd suggest you using Alternative dialog Find & Replace for Writer (AltSearch) extension:

edit flag offensive delete link more


Sorry. My posting had to sleep for a while, and then crossed yours.

Lupp gravatar imageLupp ( 2017-01-19 12:47:15 +0100 )edit

answered 2017-01-19 12:46:02 +0100

Lupp gravatar image

@robleyd obviously assumed your (theOQ's) "hard returns" were hard line breaks (Shift+Enter) while you had empty paragraphs in mind.
F&R cannot handle this as you correctly stated. The extension AltSearch can (to some degree).

edit flag offensive delete link more

answered 2017-01-21 05:59:46 +0100

GordLG gravatar image

updated 2017-01-21 11:48:26 +0100

Lupp gravatar image

This solution is not elegant, but it works to modify an entire document by replacing multiple (and variable numbers of) hard returns with single instances. Steps: 1. In the Find & Replace dialog box make sure under ‘Other options’ that ‘Regular expressions’ is checked, search for ‘$’ (no quotes), replace all with some flag or placeholder, e.g. ‘QWERTY’ 2. Use Find & Replace again, but with ‘Regular expressions’ unchecked, to remove multiple flags, leaving only those where you want a hard return. 3. Use Find & Replace, with ‘Regular expressions’ checked, to find all the remaining flags and replace them with ‘\n’ (no quotes).

(Edited by @Lupp:)
Please note the third comment below concerning hard page breaks.

edit flag offensive delete link more


(Just kidding?)
Replacing all the $ with the chosen next_paragraph placeholder will make one single paragraph of all the text. As there is still a limit of 2 147 483 647 characters per paragraph the method may already fail for Writer documents of only about 50 000 pages.
(Up to LibO Writer V 4.2 the limit was only 65535. A significant limitation! Apache OpenOffice did not raise this limit yet.)

Lupp gravatar imageLupp ( 2017-01-21 11:29:53 +0100 )edit

To remove all the multiple placeholders (QWERTY your example) I would suggest you work still with 'Regular expressions and 'Serch For' (QWERTY){2,}, 'Replace With' (empty).

Lupp gravatar imageLupp ( 2017-01-21 11:36:06 +0100 )edit

Be aware of the fact that the workaround will spoil the hard page breaks if applied to the complete document or to a selection containing such breaks.

Lupp gravatar imageLupp ( 2017-01-21 11:44:13 +0100 )edit

answered 2017-01-19 12:47:34 +0100

karolus gravatar image

@Mike Kaganski: It works … →search: ^$ and replace with nothing, deletes any empty paragraph, and of course the distance between two Paragraphs should be regulated through the Paragraph-Format Settings.

edit flag offensive delete link more


:) What works is what you posted, but that's not what OP wants, neither what was suggested as solution. I refrain from arbitrarily modifying OP's intent; I may figure quite a number of cases where using paragraphs is OK.

Mike Kaganski gravatar imageMike Kaganski ( 2017-01-19 13:49:24 +0100 )edit

I has read the OP-post … and I repeat: Don't try to "layout" your Docs with manually putting "whitespace"

karolus gravatar imagekarolus ( 2017-01-19 15:38:16 +0100 )edit

Please don't do that. No one here tried to manually layout anything here - that's you who insists on things irrelevant to discussed topic. OP gets the text from external source; that source isn't formatted as required - and needn't be, as it's apparently not a office-format. OP doesn't express desire to spend time for (possibly substantial) work on "proper" formatting of (possibly one-time-read) texts; and so his question is OK (although template approach is also viable, but possibly overkill).

Mike Kaganski gravatar imageMike Kaganski ( 2017-01-19 16:20:00 +0100 )edit

The OP ask for …replace by exactly one empty Paragraph thats IHMO manual Layout by whitespace.

karolus gravatar imagekarolus ( 2017-01-19 18:08:36 +0100 )edit

answered 2017-01-19 12:27:12 +0100

robleyd gravatar image

Find and replace with regular expressions enabled; search say \n\n\n (three hard returns) and replace with \n\n. Repeat as necessary.

edit flag offensive delete link more


AFAICS it won't work; in standard LO replace dialog, the regular expressions are limited to one paragraph.

Mike Kaganski gravatar imageMike Kaganski ( 2017-01-19 12:29:21 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-01-19 12:04:12 +0100

Seen: 45 times

Last updated: Jan 21