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.
It would be really nice if we could set the option "regular expression" as the default. I use it most of the time, and it would be easier for me if I only needed to uncheck it the few times I don't want it, instead of having to check it almost every time I search and replace. As it is now, it gets automatically unchecked every time I close the search-and-replace window. Strange, isn't it?
Do you know any trick that can accomplish that?
Posted by: Bertilo Wennergren | April 30, 2008 at 12:13 AM
I seem to be having trouble with this in OO 2.4. Have they changed the rules here?
The Help file says:
"Only finds the search term if the term appears at the end of a paragraph. Special objects such as empty fields or character-anchored frames at the end of a paragraph are ignored. Example: "Peter$". "
Which would appear to be different from what you give in your example.
Dollar sign seems to find all characters when I use it. Frustrating.
Any help appreciated.
Posted by: Jeff | May 13, 2008 at 06:09 AM
Hi Jeff,
I checked and it works the same in 2.4. "Bob$" found Bob at the end of a paragraph but not Bob Jane .
Are you checking the Regular Expressions checkbox and no others, after you click More?
Solveig
Posted by: Solveig | May 13, 2008 at 11:19 AM
Wow, this is frustrating. Using the instructions described above, I can easily find all tabs or all carriage returns in my document.
But when I want to search for only those places where a carriage return is followed by a tab, or where two carriage returns appear in a row, it does not find them at all.
So if I enter "$" into the Find box, with Regular Expressions checked, it works. But if I enter "$$" it doesn't. Any suggestions? This is the function I need MOST as an editor, to be able to take out people's manual "double space" returns, not not ALL returns, and also not ALL tabs, but only the initial ones users have stuck onto new paragraphs.
FYI, I am actually using NeoOffice 2.2.5 for Mac, but so far everything has been the same. Thanks in advance for your help!
Posted by: Cecilia Tan | October 30, 2008 at 01:13 PM
I want to search excell for the square box which represents carriage return how do I do this? Mnay Thnkas
Posted by: AARON | November 17, 2008 at 04:29 AM
Hi Aaron,
Just search for a carriage return as described here, in Calc.
Posted by: Solveig | November 17, 2008 at 05:24 AM
How do I search for, say, a comma and repalce it with a paragraph mark?
I put a "," in the "Search for" box, and a "^$" in the "Replace with box", but it does not work.
Al
Posted by: Al | December 08, 2008 at 10:56 AM
Hi Al,
This is tricky -- you put different symbols in the Replace With field than the search field (see above) even for the same thing
Search for this to find the comma literally, put a slash in front of it
/,
Replace with this to signify carriage return.
/n
and turn on the Regular Expressions checkmark under the More button.
Posted by: solveigh | December 08, 2008 at 11:04 AM
Does not work:
- Searching for "/," cannot find the commas.
If I take the slash out, it does find them but then replaces them with "/n" not a carriage return.
Checking the "Regular Expression" does not seem to make a difference.
Thanks,
Al
Posted by: Al | December 08, 2008 at 12:40 PM
Hi Al,
I'm sorry it's not working -- I tested it myself that way this morning.
Posted by: solveigh | December 08, 2008 at 12:48 PM
Well, back slashes ( "\" ) rather than forward slashes worked...
Al
Posted by: Al | December 08, 2008 at 02:45 PM
I'm nearly in tears over this. This is totally the best page on the net about searching and replacing in OO on the net, yet it doesn't answer my question. I need to find a way to search for multiple carriage returns, and none of your examples will do it, not even in regular expressions. The problem is that RE's have a way to represent the beginning of a line, but not a CR itself. A soft CR doesn't count here. Can you please help me? I can't even find a way to put in a bug report or a suggestion in the titanic OO site, which seems to complex for any mere mortal to use.
Posted by: lpb | March 08, 2009 at 10:56 PM
Dear desperate users of OO, I've just solved one of the problems that was making me crazy, so I'd like to share my experience with other users. I'm working with subtitles and I needed to replace one "enter" with the "|" character and two "enters" with one "enter". Although it was an easy task in Microsoft Word, I didn't know how to do the same in OO. After reading many internet discussions and trying out different tips I found the following: First, replace all end lines (the dollar sign) with "|" (Find: $, Replace: |). You will get a text, where one "enter" has been replaced with "|" and two enters with "|" and "enter". Now, you don't want to have "|" at the end of the line, so put ".$" (dot and dollar sign) into the "find" box and leave the replace box free. You will get the text you want. Hard work it was but I'm happy I have found the solution... Good luck to all users!
Jana
Posted by: Jana | July 23, 2010 at 03:37 AM
Jana, and others, please try this plugin. It's awesome, lets you look for a series of empty paragraph returns, or a carriage return at the end of a paragraph plus one empty return, and MUCH much more.
http://extensions.services.openoffice.org/project/AltSearch
Download then choose Tools > Extension Manager to install. Restart OOo and you'll see a new icon in the upper left corner on the main toolbar.
Posted by: Solveig | July 23, 2010 at 12:26 PM