OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

Find and replace formatting marks

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Writer
View previous topic :: View next topic  
Author Message
Slrman
Newbie
Newbie


Joined: 20 Dec 2005
Posts: 1
Location: Joo Pessoa, Brasil

PostPosted: Tue Dec 20, 2005 5:48 am    Post subject: Find and replace formatting marks Reply with quote

OpenOffice 2.0 apparently has no way to find and replace formatting marks. For example, replacing all paragraph parks with two paragraph marks. Or, replacing manual line breaks with paragraph marks.

This feature is available in Word, WordPerfect, Appleworks, and just about every modern word processor I use.

As a professional writer and editor, I really cannot work efficiently without this feature. Has anyone worked out a fix for this in OpenOffice? Without it, it's just not "ready for prime time."
_________________
Living and loving in Joo Pessoa, Brasil. The best climate in the world.
Back to top
View user's profile Send private message Yahoo Messenger
jrkrideau
Super User
Super User


Joined: 08 Aug 2005
Posts: 6732
Location: Kingston ON Canada

PostPosted: Tue Dec 20, 2005 6:02 am    Post subject: Re: Find and replace formatting marks Reply with quote

Slrman wrote:
OpenOffice 2.0 apparently has no way to find and replace formatting marks. For example, replacing all paragraph parks with two paragraph marks. Or, replacing manual line breaks with paragraph marks.

This feature is available in Word, WordPerfect, Appleworks, and just about every modern word processor I use.

As a professional writer and editor, I really cannot work efficiently without this feature. Has anyone worked out a fix for this in OpenOffice? Without it, it's just not "ready for prime time."


You might want to have a look at 'regular expressions' in the Help function and have a look at this article http://homepage.ntlworld.com/garryknight/linux/ooregexp.html

Also you may want to have a look at Iannz's FindandReplace macro at http://homepages.paradise.net.nz/hillview/OOo/

I often wonder why people assume that a fairly sophisticated office suite cannot do certain things rather than assuming that it probably can but does it differently from other packages. Confused
_________________
jrkrideau
Kingston ON Canada
Currently using Windows 7 & OOo 3.4.0 and Ubuntu 12.04 & LibreOffice 3.5.2.2
Back to top
View user's profile Send private message
Gabor
Super User
Super User


Joined: 21 Sep 2003
Posts: 610
Location: Hungary (E-Europe)

PostPosted: Tue Dec 20, 2005 7:00 am    Post subject: a different opinion Reply with quote

Sorry, jrkrideau, I must contradict you in a way.
I have a long past as an editor who works with texts. Still I am almost unable to use the overcomplicated regexp system of OOo which may be very useful for programmers and people with highly sophisticated needs but is almost impossible to learn for lesser mortals.
What the OP needs is so basic (and I could list such basic demands galore) that it should be there out of the box. All the more so, since IanNZ's tool was intoroduced much, much earlier than OOo2's first version came out - so it could easily have been incorporated. It was not.
The main problem is not that something is done in a different way but that if something is not done at all.
Just one more example: the use of the Alt key. Again it was the same author who solved the problem and again it was not incorporated.
So I think there should be no bad feelings towards those of us who did not come into the OOo world as virgo intacta but have some background in other suites and want to make use of it in OOo as well.
Back to top
View user's profile Send private message
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 9183
Location: Lexinton, Kentucky, USA

PostPosted: Tue Dec 20, 2005 8:25 am    Post subject: Reply with quote

Slrman,

In a direct how to answer to your question you need to use regular expressions to do what you want. $ represents a paragraph break when used in the Search box and \n represents a line break. For reasons unknown, \n represents a paragraph break when used in the Replace box while $ in the Replace box represents itself.

For your first example Search = $ Replace = \n\n and you must check the Regular Expression box found under More Options in v2.

Second example Search = \n Replace = \n

Logically you may have noticed that it would be impossible to find paragraph breaks and replace them with line breaks. This requires a macro. You also can not find anything past a paragraph break, specifically including another paragraph break so the oft tried Search for $$ does not work.

There are many regular expressions that you might find handy. While in Find & Replace click Help and look for the link to them.
Back to top
View user's profile Send private message
nrubdarb
Power User
Power User


Joined: 03 Jan 2006
Posts: 52

PostPosted: Tue Jan 10, 2006 6:55 am    Post subject: Reply with quote

I have read Garry Knight's article and it is very good, although obviously a touch too technical for those whose first profession is editing rather than programming.

So I can sympathize with those editors who expect a more advanced search and replace in Writer, and who do not find it.

In addition, I think it is worth quoting a sentence from the linked article:

Quote:

Replacing what you've found
In most places you find REs, you have a way to replace part of what you've found using special notation. For example, in the Perl programming language, you can search for 'Name: ([^\.]+).' Breaking this down, we want to match the letters 'Name:' followed by a space, then anything that's not a '.' (with the RE '[^\.]+'), followed by a '.' This would match 'Name: Linus'. Suppose we wanted to change 'Linus' to 'Linus Torvalds'. In Perl, we surround the part of the RE that represents the text we're searching for with parentheses and it gets assigned to a variable called '$1'. We can then replace 'Linus' with 'Linus Torvalds' using the $1 in a Perl expression:
s/Name: ([^\.]+)./Name: $1 Torvalds/

This is getting a little too technical now but suffice it to say that, at the moment, OpenOffice doesn't allow us this level of sophistication.


Well said that man! Writer might support regex 'a bit', but Textpad (to plug a text editor which I particularly like) it ain't.

Not being able to do substitution is rather a PITA and means a lot of repetitive seach&replacing at the moment!

Still, I'm not saying I'd rather use Word Wink
_________________
OOo usage is v.2.0, mostly Writer. At work I'm evaluating OOo as a solution for publishing product manuals. OS is Windows XP. At home I use OOo for all kinds of text processing. My partner will be writing her thesis using Writer. OS is Debian Linux
Back to top
View user's profile Send private message
Alan Perkins
Newbie
Newbie


Joined: 11 Nov 2004
Posts: 4

PostPosted: Fri Jan 13, 2006 9:04 am    Post subject: Re: Find and replace formatting marks Reply with quote

Slrman wrote:
OpenOffice 2.0 apparently has no way to find and replace formatting marks. For example, replacing all paragraph parks with two paragraph marks. Or, replacing manual line breaks with paragraph marks.

This feature is available in Word, WordPerfect, Appleworks, and just about every modern word processor I use.

As a professional writer and editor, I really cannot work efficiently without this feature. Has anyone worked out a fix for this in OpenOffice? Without it, it's just not "ready for prime time."


My "quick and dirty" fix for this is to use NoteTab Plus (greatest text editor). I copy OO text, paste into NoteTab, do a search and replace [^P^P and ^P] - Select All - Copy - and paste back to OO. :roll:
Back to top
View user's profile Send private message
fullerdf
General User
General User


Joined: 09 Sep 2009
Posts: 6

PostPosted: Wed Sep 09, 2009 10:01 am    Post subject: Re: Find and replace formatting marks Reply with quote

Slrman wrote:
OpenOffice 2.0 apparently has no way to find and replace formatting marks. For example, replacing all paragraph parks with two paragraph marks. Or, replacing manual line breaks with paragraph marks.

This feature is available in Word, WordPerfect, Appleworks, and just about every modern word processor I use.

As a professional writer and editor, I really cannot work efficiently without this feature. Has anyone worked out a fix for this in OpenOffice? Without it, it's just not "ready for prime time."


One approach (not in OOWriter) is to use the tools that come with Windows ... namely WordPad and NotePad.

To replace line breaks with paragraph marks (^l with ^p in MSWord):

1) Select and Copy or Cut the text with unwanted line breaks from the OpenOfficeWriter document.
2) Paste the text into a new WordPad RTF document.
3) Select and Copy the text again from WordPad.
4) Paste the text into a NotePad TXT document.
5) Select and Copy the text again from NotePad.
6) Paste the text back into OpenOfficeWriter.

Wa La -- line breaks are now paragraph characters.

Crude but it works.
_________________
Enjoy It ... Whatever IT is.
Back to top
View user's profile Send private message
JohnV
Administrator
Administrator


Joined: 07 Mar 2003
Posts: 9183
Location: Lexinton, Kentucky, USA

PostPosted: Wed Sep 09, 2009 11:30 am    Post subject: Reply with quote

Quote:
To replace line breaks with paragraph marks
It would appear to be a lot quicker to search for \n, replace with \n and check Regular Expressions.

Just don't ask me why \n stands for line break in the search box and paragraph break in the replace box.
Back to top
View user's profile Send private message
fullerdf
General User
General User


Joined: 09 Sep 2009
Posts: 6

PostPosted: Thu Sep 10, 2009 11:26 am    Post subject: Reply with quote

JohnV wrote:
Quote:
To replace line breaks with paragraph marks
It would appear to be a lot quicker to search for \n, replace with \n and check Regular Expressions.

Just don't ask me why \n stands for line break in the search box and paragraph break in the replace box.


I agree ... it sounds quicker. However, I tried that (/n) first and could not make it work. Sad Have you actually tried it?

Never had any trouble with MSWord doing find and replace (F/R) with ^l and ^p but could not make the $ and /n F/R work in OOW. I may need to try again but have seen elsewhere that you can remove line breaks but replacing them with paragraph marks is in the "can't get there" pile. I kept trying various things for about an hour before I found the procedure through WordPad and NotePad.

The text I was working on was from an email on ATTYahoo. Perhaps the kind of line breaks they use are different for some reason. Anyway, hope this is useful to someone. So far, Google and other places did not identify anything that I could make work better ... but I am no expert.
_________________
Enjoy It ... Whatever IT is.
Back to top
View user's profile Send private message
jrkrideau
Super User
Super User


Joined: 08 Aug 2005
Posts: 6732
Location: Kingston ON Canada

PostPosted: Thu Sep 10, 2009 12:29 pm    Post subject: Reply with quote

fullerdf wrote:
JohnV wrote:
Quote:
To replace line breaks with paragraph marks
It would appear to be a lot quicker to search for \n, replace with \n and check Regular Expressions.

Just don't ask me why \n stands for line break in the search box and paragraph break in the replace box.


I agree ... it sounds quicker. However, I tried that (/n) first and could not make it work.


Err John said \n . Is this a typo in the message?
_________________
jrkrideau
Kingston ON Canada
Currently using Windows 7 & OOo 3.4.0 and Ubuntu 12.04 & LibreOffice 3.5.2.2
Back to top
View user's profile Send private message
Robert Tucker
Moderator
Moderator


Joined: 16 Aug 2004
Posts: 3407
Location: Manchester UK

PostPosted: Fri Sep 11, 2009 3:54 am    Post subject: Reply with quote

Don't forget AltSearch. It may do what you want using expressions like \n and \p. (Listed under Regular on GUI.)
_________________
OpenOffice 4.0.0 and LibreOffice 4.x.x on Fedora 20, Ubuntu 13.10, Windows 8.1 Preview (Triple Boot)
Back to top
View user's profile Send private message
fullerdf
General User
General User


Joined: 09 Sep 2009
Posts: 6

PostPosted: Fri Sep 11, 2009 11:17 am    Post subject: Reply with quote

Err John said \n . Is this a typo in the message?

Yes
_________________
Enjoy It ... Whatever IT is.
Back to top
View user's profile Send private message
fullerdf
General User
General User


Joined: 09 Sep 2009
Posts: 6

PostPosted: Fri Sep 11, 2009 11:19 am    Post subject: Reply with quote

Robert Tucker wrote:
Don't forget AltSearch. It may do what you want using expressions like \n and \p. (Listed under Regular on GUI.)


I will have to look at that tool ... thanks
_________________
Enjoy It ... Whatever IT is.
Back to top
View user's profile Send private message
edembowski
Newbie
Newbie


Joined: 27 Feb 2010
Posts: 1

PostPosted: Sat Feb 27, 2010 6:57 pm    Post subject: Reply with quote

Sorry for bringing up an old thread, but I'm trying to replace '\n' for '$' as regex, and as discussed here, it doesn't work. I've tried writing a macro for it using the code below:

Code:
Sub ReplaceStrings(oContainer as Object, sSearchString, sReplaceString  as String)
   oReplaceDesc = oContainer.createReplaceDescriptor()
   oReplaceDesc.SearchCaseSensitive = True
   oReplaceDesc.SearchRegularExpression = True
   oReplaceDesc.Searchstring = sSearchString
   oReplaceDesc.ReplaceString = sReplaceString
   oReplCount = oContainer.ReplaceAll(oReplaceDesc)
End Sub


With sSearchString = '\n' and sReplaceString = '$', all line feeds become dollar signs instead of a paragraph mark. Unfortunately, there is no 'ReplaceRegularExpression = True' setting that can be used.

Any thoughts?

EDIT: OK, I was able to find something very non-intuitive. in the standard search & replace dialog, if you use '\n' in the search field, it will search for new line characters. If you use it in replace, it will replace with paragraph marks.

- Ed
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Writer All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group