[Solved] How to delete line breaks with global command?

Discuss the word processor
Post Reply
kirker
Posts: 2
Joined: Mon Feb 11, 2008 6:48 pm

[Solved] How to delete line breaks with global command?

Post by kirker »

Please answer the following questions, along with describing your problem or question.

Which version of OpenOffice.org are you using:
What Operating System (version) are you using:

----------------------------------------------------------------------------------
Your question: Is there a global command that will remove all linebreaks from a file in Open Office 2.3.1? And how would I replace all double linebreaks with paragragh breaks? Previously I have just gone back to Word, where it's obvious and easy, but there must be a way in OpenOffice.
Last edited by Hagar Delest on Wed Jun 11, 2008 11:23 pm, edited 2 times in total.
Reason: tagged the thread as Solved.
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: How to delete line breaks with global command?

Post by acknak »

Edit > Find & Replace
Search for: \n
Replace with: a space
Options > Regular expressions = YES

That will replace all line breaks with a space.

For "double linebreaks" to paragraph, use:
Search for: \n\n
Replace with: \n
Options > Regular expressions = YES

Yes, that makes no sense at all, but it works.

Obviously, you have to process the "double linebreaks" before you do the others.
AOO4/LO5 • Linux • Fedora 23
kirker
Posts: 2
Joined: Mon Feb 11, 2008 6:48 pm

Re: How to delete line breaks with global command?

Post by kirker »

Many thanks for the quick response. I would never have thought to check the regular expressions box! Is this something that most people would understand? Also, could someone say if expressions for linebreak etc are given somewhere? I did look, but couldn't find anything relevant.
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: How to delete line breaks with global command?

Post by acknak »

Is this something that most people would understand?
No--that's why it's tucked away under the "Options" view.

Regular expressions are more powerful (in some ways) than Word's wildcards but also more difficult to use. There is a full list of the pattern items in the online help, under "Regular Expressions".

You can also take a look at this article: Regular Expressions in Writer [OOo wiki]
AOO4/LO5 • Linux • Fedora 23
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: How to delete line breaks with global command?

Post by Villeroy »

Regular expressions have been around some 20 years in advanced text editors and programming languages.
A dot means "any item" like ? in shell patterns. The asterisc * means "zero or more of the preceeding item". Thus .* means "zero or more of any item" like * in shell patterns.

Short hand tutorial for those missing simple * and ?
- Use .* instead of *
- Use . instead of ?
- ^ means start of paragraph
- $ means end of paragraph
- if you search for a literal * escape it with \*
- same with any kind of braces and any of ^$.*?\&|
- in doubt escape anything but <, > and alphanumerics, since \<, \>, \n, \t and \C have a special meaning in regexes.

Some examples derived from the above set of rules:

Code: Select all

Shell pattern	Regex	Remark
*x*	x	Contains x
*x*y*	x.*y	Contains x and y
x*	^x	Starts with x
*x	x$	Ends with x
x?	x.	x followed by one of any
x.	x\.	x followed by dot
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
dutchmarco
Posts: 6
Joined: Thu Jun 16, 2011 12:35 am

Re: [Solved] How to delete line breaks with global command?

Post by dutchmarco »

Hi,


Sorry for digging up this thread, but this does not work for me.using OO 3.3.0 on XP. I followed te instructions to the lletteer but OO would just search the whole document, without result, while I can clearly see the \n\n\n. I try with \n\n (one linebreak less) and no luck either.
OpenOffice 3.3.0 on Windows XP
User avatar
Hagar Delest
Moderator
Posts: 32667
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: [Solved] How to delete line breaks with global command?

Post by Hagar Delest »

You might try the AltSearch extension for that.
LibreOffice 7.6.2.1 on Xubuntu 23.10 and 7.6.4.1 portable on Windows 10
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Solved] How to delete line breaks with global command?

Post by RoryOF »

You need to drop the More Options arrow and tick regular expressions. But AltSearch extension is the way to go.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
dutchmarco
Posts: 6
Joined: Thu Jun 16, 2011 12:35 am

Re: [Solved] How to delete line breaks with global command?

Post by dutchmarco »

RoryOF wrote:You need to drop the More Options arrow and tick regular expressions. But AltSearch extension is the way to go.
Thanks, but I already ticked that option, thay's why I was so surprised my expression didn't work. I'll try the altsearch extension, thanks!
OpenOffice 3.3.0 on Windows XP
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Solved] How to delete line breaks with global command?

Post by RoryOF »

The regular Find and Replace is limited, as far as I remember, by OOo's 64K character limit for paragraphs. AltSearch is not, because of the language in which it is written.
 Edit: Also, I think the \n in Find only matches Ctrl Enter = you may have to use $ or some combination of $ and ^$. I always have to work it out when I need it. 
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
colepjc
Posts: 1
Joined: Sun Jun 03, 2012 4:36 pm

Re: [Solved] How to delete line breaks with global command?

Post by colepjc »

Thank you, Thank you, Thank you. I have been looking for this solution for several years now.
Don't compromise yourself. You're all you've got. Janis Joplin
OpenOffice.org 3.3.0 OOO330m20(Build:9567)
Windows 7 Service Pack 1
Post Reply