Ask Your Question

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

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

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 +0200

Mike Kaganski gravatar image

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

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 +0200 )edit

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

GordLG gravatar image

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

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 +0200 )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 +0200 )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 +0200 )edit

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

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 +0200 )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 +0200 )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 +0200 )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 +0200 )edit

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

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 +0200 )edit

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

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
Login/Signup to Answer

Question Tools

1 follower


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

Seen: 52 times

Last updated: Jan 21 '17