OOo Off the Wall: Find and Replace

 in
As with most tasks, OOo offers several options for searching and replacing text or strings in your documents. Doing a little research beforehand can save time and frustration later on.

In long documents, a strong search-and-replace tool is essential for editing duties. Although many users confine themselves to simple text searches, OpenOffice.org's various searches are a match for any rival's. They also are remarkably consistent throughout Writer, Calc, Draw and Impress, the four main OOo applications.

The Find & Replace window is haphazardly arranged into basic options and advanced options that are available when the More Options button is selected. The search options fall into three main categories:

  • Location searches: searches for text strings that can be limited to specific areas or directions in the document.

  • Format searches: searches for design elements, sometimes with specific text strings but also without text strings.

  • Pattern searches: searches for patterns rather than exact text strings.

Although arranged with little logic as various check boxes and buttons, OpenOffice.org's search options provide a quick revision tool for both text and layout.

Basic Functionality

The basic operation of the Find & Replace tool in Writer is identical to similar tools found in other office applications. The text to search for is entered in the Search for field, and the replacement text--if there is any--goes in the Replace with field.

Searches are started by selecting either the Find or Find All button. If you select the Find button, the application starts at the current position of the cursor and stops successively at each instance of the text you are searching for. When it reaches the end of the document, you have the option to continue from the beginning of the text. Unfortunately, OpenOffice.org applications do not remember the starting point, so reaching the end of the document is the only marker you have for the progress of a search. This limitation makes it advisable to start a search at the beginning of every document.

By contrast, if you select the Find All button, each string that matches the search is highlighted. The text remains highlighted after you close the Find & Replace window.

When you select the Find button and a match is found, selecting the Replace button makes the substitution. Note that if the Replace with field is blank, selecting the Replace button leaves a blank where the match was.

Alternatively, once a search and replace is set up, you can select the Replace All button and have all of the substitutions made in a few seconds. This is a useful feature, but it can lead to disaster if your search is poorly planned. Usually, you are safer using the Find and the Replace buttons for one or two substitutions. Select the Replace All button once you are confident of the results.

Location Searches

Location searches are the most basic types of searches available in OpenOffice.org. As you might guess from the window layout, Whole words only is one of the most basic ways to refine a search. It ensures that results don't include, for example, "orange" when you want "range". Backwards reverses the usual search direction, which always is useful if you get ahead of yourself with multiple instances. Current selection only limits the search to the text selected with the mouse. All these location specifiers are available throughout OpenOffice.org.

Calc, the spreadsheet program, contains additional location specifiers. Entire cells is Calc's equivalent of Whole words only. It sets the search for cells that match what is entered in the Search for field rather than strings of characters. Calc searches also can be limited by Search in, which confines the search to formulas, values or notes. And, in addition to Backwards, Calc also includes Search direction, which sets whether the spreadsheet is scanned by rows or by columns. Usually, Calc searches are confined to the current sheet, but you can broaden a search by selecting Search in all sheets.

A history for the two fields in the Find & Replace window is available from its drop-down list. You can use the history to repeat a search quickly.

______________________

-- Bruce Byfield (nanday)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

OOo Off the Wall: Find and Replace

wristbands's picture

Great article on Find and Replace.Thanks for sharing.wristbands

OOo Off the Wall: Find and Replace

wristbands's picture

Great article on Find and Replace.Thanks for sharing.wristbands

The OO Community Needs to Stop Kidding Itself

Anonymous's picture

The find/replace operations in Open Office simply don't compare to those in Microsoft's products. The description here proves it -- only a programmer could love all these arbitrary symbols (which are not readily provided in the relevant dialog box). And any doubt is erased by the comments. I want to love OO, I really do, but after wrestling with a plain text document for several hours to get it ready for importation into Calc, I finally surrendered to reality, opened Word, and had it nicely displayed in Calc in about three minutes. The developers really need to take a hard look at this feature, because I would guess it's a deal-killer for a lot of potential adopters -- me included, so far.

First I want to be able to see all the nonprinting characters in my document. OO does fine here, or at least Writer does. But then I want to be able to conduct find and replace operations that correspond directly to what I'm seeing on the screen. None of this "empty paragraph" vs. "paragraph" stuff. A carriage return is a carriage return as far as the user is concerned, and OO's failure to see it that way is sure to bewilder anybody except programmers. Ideally a user could select a displayed nonprinting character, copy it, and paste it right into the dialog box. Failing that (which even Word won't do), I want some simple, intuitive codes for these characters, readily available right in the dialog box.

And I want them to operate predictably. Word has this just about right. If I'm looking at a document with a bunch of paragraph symbols in it, I can replace every one of them with anything I want by searching on ^p. Same with tabs (^t). A very common operation for me is to first mark the real paragraph breaks in a document by replacing double carriage returns (^p^p) with some arbitrary string (e.g., {*NEWPARAGRAPH*}), then stripping out all the other carriage returns, and then restoring the real paragraph breaks by reversing the original operation. Just try this with OO and see if you have not torn out all your hair before you give up in disgust, as I have done repeatedly.

I don't know if this problem originates in the underlying paradigms or algorithms or whatever. I do know that I have encountered similar frustrations with gedit, the default Gnome (Linux) text editor. All I know is, whatever the source of the difficulty, it doesn't seem to have kept the folks in Redmond from coming up with a search utility that any user can understand and use effectively. The same simply can't be said for OO, and until it can, I have to keep a copy of that Redmond product on my system.

In word processing,

Sandy's picture

In word processing, preparation and editing of large document is a common activity. The Open Office is an ideal companion for this purpose. It has all the powerful tools required to create and edit large documents. Among these the Find and Replace dialogue, is very important. It provides the writer the ability to search and replace a particular word or string of words hassle free. This option is also available for other applications of the Open Office. It can be used to change the fond or fond size of a particular word or words that spread through out the large document very easily. This tool is very helpful and a time saviour. ecommerce fulfillment

sed command

Anonymous's picture

The find and replace can be used and redirected to the same file and input file,

in this case input and outfile will be same

using -i option with sed command
sed -i 's/bar/foo/g' newfile.txt

here in all places the bar will be replaced by foo

Make a recommendation...

Richard's picture

The writer makes a point of saying the find features are "haphazardly arranged" and "arranged with little logic", but there is no suggestion about why he thinks this is the case, nor is any suggestion made for changing the organization.

Overall the article was beneficial, but support for the assertion would have made it just a smidgeon better.

"Logical" arrangement recommendation

Anonymous's picture

I Agree.

Perhaps we could start by using the structure of this article as a guide to what would make the arrangement more "logical"?

First of all, the "Match Case" and "Whole words only"/"Entire Cell" check boxes probably do belong where they are, even if they could be grouped with the rest below, because they are likely to be very commonly used. Also "Search for Styles", though less used, could go with these because it affects what appears in the "Search for" and "Replace with" text boxes.

When the "More Options" button is pressed and the dialog expands, the check boxes and buttons could be grouped according to the type of search to perform (that is, a Location, Format or Patern search), probably broken up with horizontal rules and headings "Search by Location", "Search by Format" and "Search Expressions".

  • Location Search options: group the "Backwards" and "Current selection only" together
  • Format Search options: group "Attributes..." and "Format..."/"No Format" buttons
  • Pattern Search options: group "Regular Expressions" and "Similarity" boxes (should be radios?). Put the elpsis button for Similarity closer to this option

The merrits of this arrangement are probably open to debate, as is the discussion of whether this is more or less "logical" than the current arrangement. I think in this discussion we should keep in mind what would be most useful when performing searches. Having read the article, the Find & Replace feature now makes sense to me, and I personally feel that an arrangement like above could be better than the current, though if someone else wants to better it, then please go for it.

OOo not just for kernelmonkeys

Anonymous's picture

I strongly suggest the editorial staff see the wisdom in sharing this great content with the TUX folks. Arguably, that is a better audience anyway.

find and replace for

Anonymous's picture

find and replace for non-printing characters is baloney. every suggestion has not worked

I agree - I have to go back

Dean's picture

I agree - I have to go back to Word to use find & replace to remove paragraph breaks for instance

have to check "regular expressions" box

Anonymous's picture

I was similarly confused why it didn't work when I tried to search on "$". I eventually figured out that you have to check the "Regular expressions" (whatever the heck _that_ means!) box under the "More Options" button. Ridiculous.

Sorry OO, MS Word is smarter on this one. "^p" "^l" and "^t" are intuitive. "$", "/n" and "[:space:]" are so _non-intuitive_, I can't imagine what on earth the programmers were thinking.

Webinar
One Click, Universal Protection: Implementing Centralized Security Policies on Linux Systems

As Linux continues to play an ever increasing role in corporate data centers and institutions, ensuring the integrity and protection of these systems must be a priority. With 60% of the world's websites and an increasing share of organization's mission-critical workloads running on Linux, failing to stop malware and other advanced threats on Linux can increasingly impact an organization's reputation and bottom line.

Learn More

Sponsored by Bit9

Webinar
Linux Backup and Recovery Webinar

Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.

In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.

Learn More

Sponsored by Storix