Don's Pages and my Music

Friday, February 5, 2010

Finding and Replacing Paragraph Returns and Tabs

« Using the Gallery to Set Up Frequently Used Images for UML Diagrams, D&D Maps, and Anything Illustrated | Main | Starting Page Numbering on Page 2, and Other Ways to Mix Page Styles in a Document »

December 07, 2005

Finding and Replacing Paragraph Returns and Tabs

Logo_carriage
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.
Sea1

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.
Sea3
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.

Tags

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/t/trackback/3795239
Listed below are links to weblogs that reference Finding and Replacing Paragraph Returns and Tabs:

Comments

Yes, it is very useful. I have try to use Ooo to replace word for many times, but all fail due to what I can do in word with find and replace can't be done with ooo.
Can you teach me how to replace two consective paragraph breaks (a blank lines) with one? with possible some blanks (^w) in between?
Can you teach me how to replace a section break with a normal line break? and how to convert a paragraph break into a section break?
Can Ooo search/replace only on specified styles? We do a lots of such things on daily basis. We would like to switch, but it is very difficult to find a way to complete these tasks in writer.
Thanks so much for this posting. It saved me a lot of time when trying to replace paragraph characters. I thought Writer wouldn't do it and I'd have to use Word. Glad I was wrong!
the search and replace function in writer is woefully inadequate for anyone who actually writes--as opposed to a computer geek who uses it for whatever. I frequently have to use search to find say this string:
)[space] [paragraph mark] in order to replace it with
) [no space] [paragraph mark]
As usual with open source software, there appears to be no intuitive, easy way to do this without spending 30 minutes searching the web and the help documents. Oh wait, I've done that and still can't get it to work despite the "instructions" I've found. It's enough to send me back to Word.


Hotmail: Trusted email with powerful SPAM protection. Sign up now.

No comments:

Post a Comment