Find and Replace
Find
and replace are combined in OOo,
unlike MSO.
There is no separate menu entry or key shortcut for replace. Use
Edit > Find & Replace, or Control+F , or
click the Find &
Replace icon
on the Standard toolbar.
There
is no “word forms” search.
Having
performed a search, and having closed the dialog box, the keyboard
shortcut to repeat the search is Control+Shift+F.
Searches
are paragraph-based. There is no way to search for text either side
of a paragraph marker. For example, OOo
cannot search for two blank paragraphs. To get around this problem,
and some other issues, a macro has been developed. See
IannzFindReplace (last updated 20 March 2006),
available from https://homepages.paradise.net.nz/hillview/OOo/.
Note
|
Manual
page breaks are handled internally by changing the paragraph
format of the first paragraph on the new page. When searching for
formats this option is grayed out because there is no way to
search for “manual” page breaks.
|
Tips
for find and replace
It
is common to do several find and replace operations on the same
selection, however OOo
does not “remember” the original selection. Before doing the find
and replace you can bookmark the selection in Writer, or define a
range name for the selection in Calc, so that, by using the
Navigator, the same range can be quickly reselected.
Doing
a “find all” selects all the pieces of text that match the
criteria. It is possible to perform, on all the selections, most
operations that are possible on a single selection.
Attributes
The
Attributes button
is only available in Writer’s Find
& Replace dialog. This button displays a dialog with a
series of checkboxes to find where a particular attribute has been
changed from the default for the underlying style. For example,
selecting the attribute “Font weight” will find text that has
been made bold where the underlying font is not bold (and vice
versa).
Note
|
The
attributes settings remain between uses of the Find &
Replace dialog. This can be frustrating, so always turn off
all of the attribute settings after each use.
|
Formats
This
is the same search concept as in MSO.
Note that when formats are used, there is an option to include
searching within styles. For example, searching for bold text would
not find bold text where the style is bold unless this option is
checked.
Regular
expressions
“Regular
expressions” are significantly different in OOo
from MSO’s
“Use wildcards”. See Help
> OpenOffice.org help > Index
tab > and type in “regular expressions” then move to
“Searching” and press Display. Some common examples are in
Table 1. To use regular expressions, click the More Options button of
the Find
& Replace dialog and make sure the Regular
expressions checkbox is checked. On reopening the Find
& Replace dialog, the Regular
Expressions checkbox is always unchecked.
Table 1. Sample
regular expressions
Problem
|
Search
|
Replace
|
Replace
multiple tabs with just one tab
|
\t*
|
\t
|
Replace
multiple spaces with just one space. “[:space:]” finds both
non-breaking spaces and normal spaces but not tabs. Type a
normal space in the Replace field.
|
[:space:]*
|
|
Remove
leading white space (space or tabs in any combination) at the
start of a paragraph.
|
^([:space:]|\t)*
|
|
Remove
trailing white space (space or tabs in any combination at end of
paragraph).
|
([:space:]|\t)*$
|
|
Find
paragraphs beginning with the character “a” (the rest of the
paragraph can vary) and replace the whole paragraph with a blank
line.
|
^a.*
|
|
Remove
a paragraph mark from the end of lines. for example, when having
pasted text from an e-mail message.
|
$
|
|
Replace
paragraph marks with a comma so that there is one long line
rather than many lines.
|
$
|
,
|
Replace
commas with a paragraph mark.
|
,
|
\n
|
Replace
line breaks (Shift+Enter)
with paragraph markers. (Note that \n is used for both the
Search and Replace fields. In search it is interpreted as a
newline and in replace as a paragraph mark. There is no ability
to have a line break in the replace field.)
|
\n
|
\n
|
Find
the word “the” only (do not find “then” or “bathe”).
|
\<the\>
|
|
Find
“ing” at the end of a word, for example reading or writing
but not singer.
|
ing\>
|
|
Find
whole words that end with “ing”. Note that there is a space
between the caret and the close-square-bracket character.
|
[^
]*ing\>
|
|
Select
all numbers at the start of a line where the numbers could
include a period, for example 1.1., 1.13.2 and 4.1.15.9.
|
^[0-9.]*
|
|
Note
|
The
asterisk “*” means any number of the preceding character.
Where in MSO
you might have just “*” the equivalent in OOo
is “.*” because “.” stands for any single character (like
MSO’s
“?”).
|
A
macro that makes it easier to use regular expressions in Writer, and
allows searching for “page breaks” and for things such as
multiple blank paragraphs, is available in a document called
IannzFindReplace.sxw available from
https://homepages.paradise.net.nz/hillview/OOo/.
Similarity
search
The
Similarity search option broadens the search so that what is found
does not have to be exactly the same as what was specified in the
Search for field. To specify how different it can be, select
the Similarity search checkbox in the Find
& Replace dialog.
Search
for styles
Writer
and Calc have an option in the Find
& Replace dialog: Search
for Styles (which changes to Within
Styles if Format or Attribute search is used).
Check this first if you are searching for a particular style. The
Search
for Styles field changes to a listing of the
paragraph styles in use.