[Solved] Find & replace carriage returns

Discuss the word processor
Post Reply
willfriedwald
Posts: 38
Joined: Wed Jan 04, 2012 11:38 pm

[Solved] Find & replace carriage returns

Post by willfriedwald »

I seem to remember that there's a way to do this in OO - but I can't remember how.

I would like to go through a document and replace all the carriage returns (line breaks) with a character (say an asterisk) - is there a way to do that? And then, when I've done what I have to, then replace the asterisks again with carriage returns (line breaks) .... there's got to be a way to do that.

w
Last edited by Hagar Delest on Sun Jan 20, 2013 12:44 pm, edited 1 time in total.
Reason: tagged solved.
OpenOffice 3.3.0 on Mac OS 10.7
User avatar
RoryOF
Moderator
Posts: 35079
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: find & replace carraige returns

Post by RoryOF »

Find \n Replace **** , More Options to have Regular Expressions checked.

Beware! OpenOffice does not like paragraphs longer than 64KB.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.5 LTS
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: find & replace carraige returns

Post by acknak »

First, make be what you're working with: View > Nonprinting characters: ON

Now, paragraph breaks will show as ¶ and line breaks will show as arrows: ↵

To replace the line breaks,

Edit > Find & Replace
Search for: \n
Replace with: some character
Options/Regular expressions: ON
Click "Replace all"
AOO4/LO5 • Linux • Fedora 23
willfriedwald
Posts: 38
Joined: Wed Jan 04, 2012 11:38 pm

Re: find & replace carriage returns

Post by willfriedwald »

thanks! Will try!
OpenOffice 3.3.0 on Mac OS 10.7
willfriedwald
Posts: 38
Joined: Wed Jan 04, 2012 11:38 pm

Re: find & replace carriage returns

Post by willfriedwald »

Hmmm.. I get "search key not found."

actually, I wasn't thinking about the difference between paragraph breaks and line breaks - what I'm trying to replace is paragraph breaks (hard returns) rather than line breaks...

here's the find window - is everything kosher here?

thanks!

w
Attachments
find-replace OO window.jpg
OpenOffice 3.3.0 on Mac OS 10.7
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: find & replace carriage returns

Post by acknak »

If you want to manipulate paragraph breaks, you probably need to use the "AltSearch" extension: http://extensions.openoffice.org/en/project/AltSearch

Writer alone is very limited. You can replace a paragraph break using the single character $ in the search-for box. If you replace enough of them (remember, this joins paragraphs together) to make a single paragraph that's too long (~15 letter-size pages, single-spaced) you may lose the overflow.
AOO4/LO5 • Linux • Fedora 23
User avatar
RoryOF
Moderator
Posts: 35079
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: find & replace carriage returns

Post by RoryOF »

Try Find $ Replace *, Regular Expressions checked etc.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.5 LTS
willfriedwald
Posts: 38
Joined: Wed Jan 04, 2012 11:38 pm

Re: Find & replace carriage returns

Post by willfriedwald »

Okay, I now have the ALT FIND & REPLACE installed.

in this block of text,

1. Caution Blues [Blues In Thirds] (A) 2:58*@(Earl Hines)*@2. A Monday Date (A) 3:17*@(Earl Hines)*@3. I Ain’t Got Nobody And Nobody Cares For Me (B) 3:12*@(Graham-Williams-Peyton)*@4. 57 Varieties (B) 3:14*@(Earl Hines)*@5. Sweet Ella May (C) 2:42*@(Alpert-Renard-Robinson)*@6. Everybody Loves My Baby (C) 3:15*@(J. Palmer-S. Williams)*@7. Good Little, Bad Little You (D) 2:33*@(B. Green-S. Stept)*@8. Have You Ever Felt That Way (D) 3:02*@(S. Williams-A. Castleton)*@9. Beau-Koo Jack (E) 2:47*@(Armstrong-Hill-Melrose)*@10. Sister Kate (E) 3:04*@(A.J. Piron)*@


I'm trying to replace

)*@

with paragraph breaks "\p"

so that it looks like

1. Caution Blues [Blues In Thirds] (A) 2:58*@(Earl Hines
2. A Monday Date (A) 3:17*@(Earl Hines
3. I Ain’t Got Nobody And Nobody Cares For Me (B) 3:12*@(Graham-Williams-Peyton
ETC

I can't figure out how to replace a "regular expression" with a "non-regular expression."

If I have "regular expressions" un-checked, it can find the ")*@" but it replaces it with just \p, not an actual paragraph break - and vice versa, If I have "regular expressions" checked, then it can't find the ")*@" -

any suggestions?

thanks again...

W
OpenOffice 3.3.0 on Mac OS 10.7
User avatar
RoryOF
Moderator
Posts: 35079
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Find & replace carriage returns

Post by RoryOF »

Instead of \p use \n. \p is used in MS Word; OpenOffice uses \n.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.5 LTS
willfriedwald
Posts: 38
Joined: Wed Jan 04, 2012 11:38 pm

Re: Find & replace carriage returns

Post by willfriedwald »

thanks, but it's the same difference, it inserts the code as code rather than the line break (or carriage return) that it's supposed to represent,

this is what I get :

1. Caution Blues [Blues In Thirds] (A) 2:58*@(Earl Hines\n2. A Monday Date (A) 3:17*@(Earl Hines\n3. I Ain’t Got Nobody And Nobody Cares For Me (B) 3:12*@(Graham-Williams-Peyton\n

and THIS is what I want :

1. Caution Blues [Blues In Thirds] (A) 2:58*@(Earl Hines
2. A Monday Date (A) 3:17*@(Earl Hines
3. I Ain’t Got Nobody And Nobody Cares For Me (B) 3:12*@(Graham-Williams-Peyton

I have tried it with "regular expressions" both checked and unchecked, and I don't get the right result either way...

thanks for any additional input!

w
OpenOffice 3.3.0 on Mac OS 10.7
User avatar
acknak
Moderator
Posts: 22756
Joined: Mon Oct 08, 2007 1:25 am
Location: USA:NJ:E3

Re: Find & replace carriage returns

Post by acknak »

willfriedwald wrote:... in this block of text, ... I'm trying to replace )*@ with paragraph breaks "\p" so that it looks like ...
...
Thanks. It's much simpler to help when there is a clear sample!

Edit > Find & Replace
Search for: \)\*@
Replace with: \n
Options/Regular expressions: ON
Click "Replace All"

That works for me with your sample.
AOO4/LO5 • Linux • Fedora 23
willfriedwald
Posts: 38
Joined: Wed Jan 04, 2012 11:38 pm

Re: Find & replace carriage returns

Post by willfriedwald »

and for me too! thanks! this worked in the standard "find & replace," I didn't even need to implement the "alt find & replace!"

will
OpenOffice 3.3.0 on Mac OS 10.7
gbonehead
Posts: 1
Joined: Fri Oct 11, 2013 9:15 pm

Re: [Solved] Find & replace carriage returns

Post by gbonehead »

One note that might help someone else struggling (as I was) until I experimented a bit.

It's counter-intuitive, but sometimes you want to replace \n with \n.

You would want to do this when you want to replace the line breaks (like you get when you're pasting from the web) with actual paragraph breaks. As mentioned above, if you have nonprinting characters turned on, the paragraph breaks show as ¶ and line breaks will show as arrows: ↵

For some inexplicable reason, the \n in the Find box matches the line breaks (↵), yet in the Replace box, the \n inserts a paragraph break (¶).

Heaven help the person who wants to replace paragraph breaks with line breaks, I guess :)
OpenOffice 3.4.1 on Windows 7 / some other version on my home laptop
Post Reply