(Originally published December 2005)
John V and Gabor at the OpenOffice.org Forum helped me find this solution. See also this blog on bringing text files into spreadsheets.
Call them carriage returns, line breaks, paragraph marks, whatever, sometimes you want fewer of them. Maybe you've brought in some ASCII text that had a line break or two after every paragraph and now with formatted text you don't need it. Or you're turning a spreadsheet or database into text or vice versa.
At any rate, it would be nice to use the Find and Replace window to quickly find'em and change them to whatever you want: nothing at all, or the phrase "el elegante" or whatever.
Note: If you're a macro kind of person, see this page on the ooo forum.
Searching and Replacing, Step by Step
In your OpenOffice.org document, choose Edit > Find and Replace or press Ctrl F. The Find and Replace window will appear.
In the Find and Replace window, enter the symbol for what you want to search for, in the Find field. Here's a quick reference to the symbols to enter for what you're looking for.
- Regular carriage returns are $
- Soft returns inserted with a Shift Return, are \n
- Just an empty paragraph, i.e. a carriage return but with no text on that line, is ^$
- Tabs are \t
In the Replace field, you typically don't enter anything since you're probably just trying to get rid of whatever you're searching for.
- If you want to replace something with a carriage return, put \n in the Replace field.
- If you want to replace one carriage return with two, put \n\n in the Replace field.
- One thing--you can't replace something with soft returns. As you see, a \n in the Replace field turns into a normal hard return.
- Just use \t normally, in both the Search and the Replace fields, for a tab.
Once your Find and Replace fields contain what they should, click the More Options button. Select the Regular Expressions checkbox. This will make the program look for what those codes represent, rather than literally those characters.
If you're using a mix of regular expressions and normal characters, you might need to use a \ in front of anything you want evaluated normally. For instance, if you really are looking for the symbol $ but you want to replace it with a carriage return \n, then you need to actually search for \$ in the Search field and replace it with \n because $ is a special character.
This illustration shows you're looking for a carriage return (any carriage return), and you're going to replace it with nothing.
Click Find. The first instance (from where the cursor was) of the thing you're looking for will be highlighted.
Click Replace to do the replacing.
And so on. Keep going until you're done. Use Replace All only when you're absolutely positive you'll get the results you want.
Thanks for this tip, very helpful!
Posted by: Harry | February 06, 2008 at 06:42 AM
Where is this documented in the online help of OO Writer ?
I did not get any help there ! The chapter: Special character doesn't say it, mentions only hyphen.
Are there other/additional codes one can enter ?
Posted by: René Bach | November 02, 2008 at 07:05 AM
Hi Rene,
The help topic is "List of Regular Expressions." You can type that into the help search box.
Posted by: Solveig | November 02, 2008 at 07:16 AM
Thank you!!!!
I have wondered for a couple of years--literally--how this could be done. I even occasionally returned to M$ WORD just to get rid of those unwanted linebreaks.
I always figured there that Writer had a way to do this, as it is all-in-all a good piece of software.
Mike
Posted by: Cristianismo Primitivo | July 21, 2009 at 08:53 AM
Here is a crude way to do a line break with a paragraph mark (^l to ^p in Word).
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.
Posted by: DougF | September 09, 2009 at 11:43 AM
This feature is really hard to figure out without this blog post. Can I request a drop down list of special characters for find&replace?
Posted by: Christopher Dodd Thompson | December 05, 2009 at 09:11 AM