Using Replace to remove line breaks

Discuss the word processor
Post Reply
Dr Spyn
Posts: 2
Joined: Mon Jan 14, 2019 10:34 pm

Using Replace to remove line breaks

Post by Dr Spyn »

I have a long text document with manual single line breaks I'd like to replace with a space. When I place \n in the Search For field and a space in the Replace With field, then click on Replace All, the message "Search Key Not Found" appears. Please reply with a verbose step-by-step explanation as I'm a nitwit.
OpenOffice Ver. 4.1.5/Rev. 1817496/2017-12-11 17:25/Win 10
User avatar
Zizi64
Volunteer
Posts: 11359
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Using Replace to remove line breaks

Post by Zizi64 »

When I place \n in the Search For field and
The \n will search an find the Shift-Enter type line breaks only - if the Regular Expressions option is checked in the other options area of the dialog.
Please stusy the the Regular expressions in the HELP or on this page:
https://help.libreoffice.org/Common/Lis ... xpressions
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
RoryOF
Moderator
Posts: 34613
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Using Replace to remove line breaks

Post by RoryOF »

Turn on /View /Non printing characters.

Note the line ends - are they left pointing hooked arrows (line breaks) or backwards P characters (Pilcrows)? If the left arrows, enter \n in Find. If Pilcrows, enter $ in Find. In either case in Replace enter a single space.

Before clicking Replace All button, drop More Options on the F&R window and select "Regular Expressions". Now click Replace All.

Be advised that if your document is long - more than 64K characters (say about 10,000 words)- this is not a good thing to do, as OO hangs with paragraphs longer than 64K characters, often about 15 pages.

The non printing characters display does not print, and is turned off by using the same command (or pressing the backwards P button on the toolbar).
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
esperantisto
Volunteer
Posts: 578
Joined: Mon Oct 08, 2007 1:31 am

Re: Using Replace to remove line breaks

Post by esperantisto »

You might want to try the Process ends of lines/paragraphs… feature of OOoFBTools.
AOO 4.2.0 (of 2015) / LO 7.x / Win 7 / openSUSE Linux Leap 15.4 (64-bit)
Zoe25
Posts: 7
Joined: Fri Sep 20, 2019 2:19 am

Re: Using Replace to remove line breaks

Post by Zoe25 »

The method from RoryOF (Find and Replace) Does work with long documents. (One million words in my books)
SUCCESS! Mostly. Have to add spacing manually in a few hundred areas (Chapters). Better that the >32,000 Line Breaks that were Replaced with one space. (Gives two actual spaces.)
(I tried two spaces in Replace, and it gave 4 spaces. lol)
Yes, the dollar sign (for the backwards P) and one space worked in Find and Replace in under 30 seconds. Regular Expressions checked. :)
Thank you!
OpenOffice 4.1.6 on Windows 10
User avatar
RoryOF
Moderator
Posts: 34613
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Using Replace to remove line breaks

Post by RoryOF »

One needs to consider what F&R is doing. I find it is best often to use multiple simple F&R passes, rather than try to do everything in one complex F&R process.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
Post Reply