[Solved] Replacing paragraph mark..

Discuss the word processor
Post Reply
maya90
Posts: 3
Joined: Wed Jul 30, 2008 6:28 pm

[Solved] Replacing paragraph mark..

Post by maya90 »

hi,

how do you replace paragraph marks, tabs, etc.. in Open Office Writer? (in MS Word, you would type, for example, ^p for paragraph mark, but this is not working in Open Office.. how do you do this in OO pls..) thank you very much..
Last edited by Hagar Delest on Thu May 26, 2011 8:22 am, edited 1 time in total.
Reason: tagged [Solved].
OOo 2.4.X on MS Windows Vista
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: replacing paragraph mark..

Post by acknak »

OOo uses a far more powerful (but also far more complicated, and at the same time less complete) feature:
Regular Expressions in Writer [OOo wiki]
AOO4/LO5 • Linux • Fedora 23
User avatar
r4zoli
Volunteer
Posts: 2882
Joined: Mon Nov 19, 2007 8:23 pm
Location: Budapest, Hungary

Re: replacing paragraph mark..

Post by r4zoli »

Welcome on board,
before posting please read first, the Survival Guide, try to search on forum and you get the answers faster.

I think http://user.services.openoffice.org/en/ ... f=7&t=6818 this link gives answer your question, you problem using regular expression. Good tutorial on oooninja webpage.
AOO 4.0 and LibO 4 on Win 8
Hungarian forum co-admin
popeye
Posts: 4
Joined: Fri May 20, 2011 1:25 am

Re: Replacing paragraph mark..

Post by popeye »

Oh dear. I have the same question: can someone tell me where to look for the answer please? I am not sure I have the time or the disposition to go and research regexp to find out how to perform a simple "search and replace for paragraph marks" operation.
Word makes it easy. BBEdit makes it easy.Why should it be so difficult in OpenOffice?
Thanks.
OpenOffice 3.3 on Mac OS X
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Replacing paragraph mark..

Post by acknak »

There are a bunch of handy examples here: Regular expression samples [OOoNinja]

If you want specific suggestions, you'll have to tell us exactly what you're trying to do--replace paragraph marks with what? What are you trying to accomplish?
AOO4/LO5 • Linux • Fedora 23
popeye
Posts: 4
Joined: Fri May 20, 2011 1:25 am

Re: Replacing paragraph mark..

Post by popeye »

Thanks acknak, but I am really not a programmer and cannot understand those examples. I am a plain, boring user, trying to move away from MS Office. I didn't realise it could be so time consuming.
So I'll try to explain what I am trying to accomplish, although I assure you I have no need to consider examples when performing Search and Replace operations in all the other text editors/word processors I am familiar with (Word, BBEdit, Nisus, TextEdit, many others).
In this particular case, I wanted to reflow some text where an email program had broken off the lines at 80 characters or so. In BBEdit (for example), I know I can do that by entering \n in the search field, and whatever value I wish in the replace field (could be a space, a tab, a || or any other "marker" if I wish). So how do I accomplish this in OO Writer? Thanks.
OpenOffice 3.3 on Mac OS X
User avatar
MrProgrammer
Moderator
Posts: 4895
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Replacing paragraph mark..

Post by MrProgrammer »

Take a look at Alternative dialog Find & Replace for Writer. If the page is slow to load, try again later. They seem to be making infrastructure changes to some of the OOo pages and sometimes they aren't available.
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Replacing paragraph mark..

Post by acknak »

Edit > Find & Replace
Search for: $
Replace with: space (or whatever)
Options/Regular expressions: ON (checked)

Click "Replace all".

Note that this is a special case. When you use "$" all alone, it is treated as the actual line break for purpose of replacement. That is not the case when you use $ along with other things in the "Search for" field. For example, you can't use "$$" to search for two consecutive line breaks.
AOO4/LO5 • Linux • Fedora 23
popeye
Posts: 4
Joined: Fri May 20, 2011 1:25 am

Re: Replacing paragraph mark..

Post by popeye »

Edit > Find & Replace
Search for: $
Replace with: space (or whatever)
Options/Regular expressions: ON (checked)

Click "Replace all".
Great. Thank you acknak, this is exactly what I was looking for. Appreciate your help :-)
OpenOffice 3.3 on Mac OS X
popeye
Posts: 4
Joined: Fri May 20, 2011 1:25 am

Re: Replacing paragraph mark..

Post by popeye »

MrProgrammer wrote:Take a look at Alternative dialog Find & Replace for Writer. If the page is slow to load, try again later. They seem to be making infrastructure changes to some of the OOo pages and sometimes they aren't available.
Thanks Mr Programmer. I'd prefer a built-in function, as in all the other "writers" I've used. Do you know whether future OO versions might include this alternative/extended search&replace funcionality?
OpenOffice 3.3 on Mac OS X
jameskhazar
Posts: 1
Joined: Mon Aug 15, 2011 11:53 pm

Re: [Solved] Replacing paragraph mark..

Post by jameskhazar »

I've spent years avoiding learning regexp sytnax, it's serious overkill for such a simple (and often necessary) search and replace. It comes up often for me, like copying from a web page of a data table. For some reason the copy created a set of tabs and paragraph insertions that made it impossible to paste into a spread sheet. Simple to do in Word, find and replace ^t^p^t with ^t. After a half an hour's research and attempts with regex, still can't get it to work. I thought OpenOffice wanted to be on an even keel with MS Word. The lack of this one thing may force me to go back...
OpenOffice 3.3.0
OOO330,20 (Build:9567)
OS X 10.7
mriosv
Volunteer
Posts: 651
Joined: Mon Mar 09, 2009 1:12 am
Location: Galiza (España)

Re: [Solved] Replacing paragraph mark..

Post by mriosv »

There is an extension to do it:
Alternative searching 1.3.2 (AltSearch.oxt)
Copyright (c) 2007 Tomas BILEK
http://extensions.services.openoffice.o ... /AltSearch
LibreOffice 3.5.4 AOo-3.4 on Win 7 Ultimate
arndtwc
Posts: 1
Joined: Fri Jan 23, 2015 7:20 pm

Re: [Solved] Replacing paragraph mark..

Post by arndtwc »

I will agree with what jameskhazar said on Mon Aug 15, 2011 6:00 pm. I want to search for a paragraph marker and replace with two paragraph markers. Simple to do in MS Word. But Openoffice it is not possible. I am going back to MS Word.
Windows XP, Windows 7, with Openoffice 4.1.0
User avatar
RoryOF
Moderator
Posts: 34586
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: [Solved] Replacing paragraph mark..

Post by RoryOF »

Wrong, wrong wrong!

Use Find and Replace. In Find box put $. In Replace box put \n\n. Drop More Options, check Regular Expressions, then do either single Replaces, or Replace All.

But if you are happier with MS Word, off you go.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: [Solved] Replacing paragraph mark..

Post by acknak »

arndtwc wrote:... I want to search for a paragraph marker and replace with two paragraph markers. ...
Edit > Find & Replace
Search for: $
Replace with: \n\n
Options/Regular expressions: ON

Click Replace All

Note: The replacement does not seem to happen for the last paragraph in the document, for some reason.
AOO4/LO5 • Linux • Fedora 23
John_Ha
Volunteer
Posts: 9583
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: [Solved] Replacing paragraph mark..

Post by John_Ha »

arndtwc wrote:I am going back to MS Word.
Be sure to let us know if the MS Word forum is as good as this AOO forum for helping users to solve problems.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: [Solved] Replacing paragraph mark..

Post by Lupp »

Ok. I've noticed the topic being marked [Solved].
What I missed - and still cannot find: How was it solved?

The original subject was: "Replacing paragraph mark.." .

I agree that we possibly haven't to replace an actual character (or2). It's about merging 2 or more paragraphs into one - and there will surely be implications (think alone of the complicated paragraph styles). This aside, and possibly forced to accept imperfect results : How can I simply merge 3 empty paragraphs into one? This a surely not too excentric task - and often needed.

Even the possible shortcomings of the ICU engine for regular expressions accepted there should be a way to also actually find the paragraph break as something we can delete or replace by something else and not only as a condition restricting the acceptance of a pattern like a "word boundary" e.g. Using \n for 'hard line break' when searching but for 'new paragraph' when replacing is a grave oddity IMO. Approximately the same with using $n for the nth variable containing found text"glued-together".
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: [Solved] Replacing paragraph mark..

Post by acknak »

Lupp wrote:... and still cannot find: How was it solved?
As far as I see, the problem is that there are several related questions being asked and answered.

The actual answer depends on the document content and exactly what you want to do with it.
... How can I simply merge 3 empty paragraphs into one? ...
This precise task is not possible with OO, unfortunately.

However, there is (maybe) a workaround: you can remove empty paragraphs using the pattern ^$ and replacing with nothing. This is handled as a special case (I believe).

As far as I understand, this is not a limitation in the ICU regex library, but in the way the document data is structured and accessed by the code. It seems that fixing it may require a large effort. The switch to ICU was a huge improvement; I hope it will be cleaned up someday.

All that aside, I do a lot of messy text clean up and OO's find & replace works well enough to get the job done, even with its limitations.
AOO4/LO5 • Linux • Fedora 23
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: [Solved] Replacing paragraph mark..

Post by Lupp »

Thanks "acknak"!
Writer is not the component of Office I use most (and I never use Impress) ... Nonetheless I had more than once the actual need to merge "superfluos multiple inter-paragraphs" into single ones. I had to do the most of it manually.

How costly an enhancement?

I already mentioned in my post above that the present 'Find & Replace' is not capable of inserting a hard line break. At least the search code \n for it will, used in 'Replace with', cause insertion of a new paragraph. (Do you know another representation stepping in for \n ?) That is (Sorry!) idiotic. And it is not related with deeply coded-in properties of the regex engine. I judge it to be a thoughtlessness. We need another helper for inserting paragraphs. And we need a "Find & Replace" dialogue passing the line-break U+000A represented by \n e.g.to the ReplaceDescriptor. That's all. You can test it: Find an existing pattern (\n)a and use the (Sorry again: idiotic!) paraphrase Q$1R in 'Replace with'. Yo will get what should be expected: Q followed by a hard line break followed by R. The engine is capable of it. The user interface isn't.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
John_Ha
Volunteer
Posts: 9583
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: [Solved] Replacing paragraph mark..

Post by John_Ha »

... How can I simply merge 3 empty paragraphs into one? ...
Will something like this work?

1 Replace every paragraph return by some unused sequence like £*f3@#Q. This will mess up the document in spades :-)

2 Search for £*f3@#Q£*f3@#Q£*f3@#Q and replace it by £*f3@#Q. That converts the three to one.

3 Search for £*f3@#Q and replace it by a paragraph return, which should automagically restore the document.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
Magnet8
Posts: 1
Joined: Fri May 28, 2021 2:42 pm

Re: Replacing paragraph mark..

Post by Magnet8 »

acknak wrote:Edit > Find & Replace
Search for: $
Replace with: space (or whatever)
Options/Regular expressions: ON (checked)

Click "Replace all".

Note that this is a special case. When you use "$" all alone, it is treated as the actual line break for purpose of replacement. That is not the case when you use $ along with other things in the "Search for" field. For example, you can't use "$$" to search for two consecutive line breaks.
You are life savoir, my friend!
LibreOffice 6.4.7.2 on Linux Mint 20.1 beta version
Post Reply