| Barry MacDonnell's
Toolbox for WordPerfect
Macros, tips, and
templates for Corel® WordPerfect® for Windows®
| Page updated Jul 8, 2021
Main tips page | Browse more tips
How to efficiently use "Find:"
in the Edit, Find and Replace (F&R) dialog
Related pages -Enhancing the Find and Replace feature
Using Windows or QuickFinder to search inside other WordPerfect files (.wpd, .wpt, .wcm) on your system
REPLACEM - Replace multiple words in one pass
DELCODES - Delete multiple specified format codes in one pass (related macros in that ZIP file can delete extra adjacent hard returns and/or delete "empty" paired codes ("orphaned" codes))
REPLACE CODES - Change, replace, or enhance any of several text attributes (bold, italics, underline, etc.), font types, or font sizes in one operation (optionally pausing for confirmation at each item found)
Starting and repeating a Find operation
(For more information on using Find and Replace,
Most often you probably just type a word or phrase into the
(Edit, Find and Replace) "Find:" field, (possibly) make various selections from the Find
and Replace dialog's menu [also see
other Tips below], then either search for the
item with one of the find buttons (Find Next or Find Previous) or replace the item (Replace or Replace All) in the document
with whatever you typed into the "Replace with:" field.
You can also find, add, or replace format codes using the Find and Replace dialog's menu Match, Codes and/or Replace, Codes choices to insert the code in the "Find:" or "Replace with:" fields. You might have to scroll down the list(s) to find some codes. Note that you must have Reveal Codes open (on the View menu) to search for format codes. [See Tips below for some limitations when searching for format codes. Since some format codes are paired codes, also see the DELCODES and REPLACE CODES links in the left sidebar, which can make it easier to deal with paired codes.]
You can also search for (or replace) one or more space characters: Just press the Spacebar key to insert a space character in the field.
Similarly, you can search for (or replace) WordPerfect symbols such as the typographical em-dash or en-dash by inserting them in the field with Ctrl+W.
You can even search for (or replace) some character-code combinations — e.g., one or more characters with an adjacent single (not paired) format code — by including both the characters and the code in the F&R field, in the same manner as they are they appear in Reveal Codes. (See Method B for the best technique.)
You can first select
the words and/or format codes* in the document, then bring up the F&R dialog
(Edit, Find and Replace ... or Ctrl+F), and the words (and/or codes) will
be automatically entered in the "Find:" field.
Alternatively, you can select the
items — including any symbols or format codes — then copy the selection to the clipboard (Ctrl+C or
Ctrl+Insert) and paste the items (Ctrl+V or Shift+Insert) from the document directly into
the "Find:" field (or "Replace with:" field).
you have already searched for items they will appear in the "Find:" field's
drop list so that you can click on them to use them again.
- Either use
the down arrow at the right side of the field or
scroll the recent list with the keyboard's down arrow when the cursor
is inside the field.
- You can even copy an item in either field ("Find:" or "Replace with:") with
Ctrl+C and then paste it into the other field
with Ctrl+V. (You can also cut it from the field with Ctrl+X.)
- [New in WordPerfect version 2021:
useful when selecting format codes in the document: Use Shift+Arrow to
select ("paint") the items in the document text while observing them in Reveal Codes.
☼ To quickly and efficiently repeat a Find operation (and see some other tips): Enhancing the Find and Replace feature.
☼ In most cases, the alternative Method B above will not present any problems, but see below for more information.
☼ Search inside other documents: You can use Windows or Wordperfect Office's QuickFinder (if installed with WordPerfect Office) to search inside other WordPerfect files (.wpd, .wpt, .wcm) on your system: See here.
As with manually typing words into the F&R fields, pre-selecting words, or copying a selection and then pasting it into the field is limited by the program to just 79 characters and spaces.
If your intent is to search for a selection of text in the document that is longer than 79 characters/spaces, this can present problems. (Not to mention that it probably is unnecessary to use such long strings in a simple find operation!)The "disappearing text" effect
One issue with a long selection of text is that if it has more than 79 characters WordPerfect will simply ignore it and not put it in the Find field. This might cause you to wonder why the F&R feature didn't work when it worked in the past (but with shorter selections).
The reason WordPerfect ignores such larger blocks of selected material is that it assumes you want to search in the selection, not search for the selection. In fact, it will enable "Search in Selection" in the F&R Options menu. It then waits for you to type something in the Find field (it may already have placed the previous search material there).
This is "working as designed," and it might be what you want to do some of the time. Just be aware of what WordPerfect assumes you want to do depending on the size of your selection of material. To search for words in the document, keep the selection short. Otherwise,WordPerfect will set things up to search inside the selection for whatever you type in the Find field.The "truncation effect"
Another issue: "Characters" in the context of
selecting material also
means WordPerfect symbols (accessed with Insert, Symbol or
<Ctrl+w>) and format codes (Bold, Italics, hyphen codes, etc.).
So if you copy a short selected block of text that contains these codes, these items are counted toward the 79 "character" limit (see above) when you paste them into the Find field (or when you let WordPerfect automatically insert them in the Find field as discussed above).
Therefore, the block of text might become truncated (cut off at the end) in the Find field. Since the F&R field is relatively small, you might not notice this with a long sentence, and therefore you might not replace what you expect to replace when your click Replace or Replace All.
Moreover, as with merely selecting large blocks of text, copying and pasting a selection larger that 79 characters/codes also causes WordPerfect to enable "Search in Selection" in the F&R Options menu. This is probably not what you want.
Again, it is best to keep your selections short unless you really intend to search inside the selection itself.
[Incidentally, finding and replacing large blocks of text in multiple locations in often-used documents can be easily done with text variables.]An alternative
One way to work around many "truncation effect"
problems (other than to remember to keep selections shorter than 79
characters/codes) is to first paste the copied selection elsewhere in
the document (or in a blank document) without any format codes by using
Edit, Paste Special, Unformatted text (see here
for more). Then re-select and re-copy the item, and paste the now
unformatted version into the Find field.
This can help with the issue, but note that pasting a copied selection of document text that contains hyphen codes ([- Hyphen]) back into a document as Unformatted text will (in recent versions of WordPerfect) convert the hyphen codes to hyphen characters ("-") (see here
— which are different things to the Find and Replace feature. Searching
for one type of hyphen will fail to find the other type of hyphen.
In any case, this workaround might only be useful for text that approaches 79 characters — counting any
Macro search routines are also limited to 79 characters in a SearchString() command; however, storing a selection of text in a macro variable automatically strips out any format codes. The Search (and Replace, if used) operation will succeed since it looks for only the characters and spaces — up to the 79 character limit, of course.
See Footnote 1 below for a code snippet to test for the length of a selected string.Other tips and caveats
☼ The Find and Replace dialog has its own menu:
• The Help menu choice on that dialog offers some basic information about finding and/or replacing text, specific fonts, case-specific words, whole/partial words, etc.
• The Type menu's default choice is "Text" — but you can also search for "Word Forms" (e.g., "like" also finds "likes," "liked," "liking," etc.) or even certain "Specific Codes" such as a specific left margin setting (e.g., 1.75") or a font type (e.g., Ariel) or a font size (e.g., 13-point).
- See below for more tips and examples of how to find and replace specific font type codes or font size codes. For more information use WordPerfect's F1 Help Index and search for "Find and Replace - code search" which shows how to find, replace, or delete various specific formatting codes (page margin codes, font codes, etc.) and 400+ general formatting codes.
- Certain format codes that apply text attributes such as bold, italics, redline, highlighting, relative size, etc., can be searched, replaced, added to ("augmented"), or removed easily with a macro. See Replace Codes in the Library.
• In the Match and Replace menu choices -
▸ The Match menu choice is only active when the cursor is inside the "Find:" field. Similarly, Repalce is only active when the cursor is inside the "Replace with:" field.
▸ Note that Match, "Whole Word," is disabled (un-ticked) by default for the current operation.
If that choice is left disabled, if you search for "Word" you can find both "Word" and "WordPerfect".
On the other hand if you enable (tick) it you can find just "Word". (But don't assume it will remain enabled for subsequent searches during the current session since the program usually will return it to the normal default as soon as you exit the Find and Replace dialog.)
▸ Using Match (or Replace), "Case" (a.k.a., "case sensitive") should be self-explanatory: For example, if the option is enabled you can search for "Word" but ignore "word". Or search for "wordperfect" and replace with "WordPerfect".
▸ Using Match (or Replace), "Font" brings up a separate Match (or Replace) Font dialog where you can choose "Text only," the Font, Point size, and/or related text attributes (e.g., bold; italics; redline; superscript; large; etc.) that were applied (or in the case of Replace, should be applied) to the item(s) found in the document.
▸ Using Match (or Replace), "Codes":
When the cursor is in the "Find:" field you can use the Match, "Codes..." option to insert various format codes in that field by choosing them from the Codes dialog that appears.
Similarly, when the cursor is in the "Replace with:" field you can use the Replace, "Codes..." option.
♦ ♦ ♦ To find or replace normal tabs insert the Left Tab code from the Codes dialog. You'll need to scroll down in the dialog to locate it:
♦ ♦ ♦ To find or replace page breaks or hard returns insert the HPg or HRt code, respectively:
♦ ♦ ♦ To find characters or words using "wild card symbols" insert the appropriate code from the Codes dialog, as follows:
? (One Char) represents each single character or symbol at that specific location in the Find string of characters:
* (Many Char) represents either any character/symbol or several sequential characters/symbols at that specific location in the Find string of characters:
These two codes are similar to the wildcard symbols used in various other search programs: "?" for single characters and "*" for multiple characters.
But since they are "instructions" for WordPerfect that are included as part of the search string they need to be codes and not typed characters (such as "?" and "*"). Otherwise, the program would search for the actual keyboard characters "?" and "*".
Note especially that "character" here means letters, numbers, punctuation, and/or symbols (Insert, Symbol). It does not include attribute codes (e.g., [Bold]) or white spaces (i.e., word separators — the codes (e.g., [Tab] and character spaces for marking off words) of any kind (as noted here).
♦ ♦ ♦ To find a word or phrase and add a text attribute (see under Format, Font, Appearance) such as bold, italics, Redline, etc., to one or all such items in the document, see Footnote 2 below.
☼ The Codes dialog has lots of codes so you may need to scroll down to locate the one you need (e.g., Left Tab].
Related tip: You can also just type the first letter(s) of the code's name when you are in the Codes dialog to quickly move down in the list. For example, to locate the code for a Left Tab, type "left" in the field. Even typing just the first letter or two can often get you to the code, or at least close to it.
☼ An alternative to using the Codes dialog is to click inside the Reveal Codes window and then select and copy (Ctrl+c) the code before you open the F&R dialog. This will automatically place it directly into the F&R "Find:" field when you open the F&R dialog.
Related tip: Use Shift+arrow keys inside Reveal Codes to more precisely select just the code (or the ocde-plus-text if that's what you need).
☼ To quickly remove specific codes throughout a document in one operation see DelCodes in the Library.
• In the Action menu -
▸ You can set the search to "Select Match" to select ("highlight") the item when it is found. This is the normal default setting.
▸ You can set the search to have the cursor stop either Before or After the found item.
▸ If you use "Extend Selection" WordPerfect will select everything from the current cursor position up to and including the found item. (If the text is still selected when you dismiss Find and Replace, you can keep it selected while adjusting the amount of text it includes by using the Shift+arrow keys.)
▸ Important: As noted, "Match Selection" is the normal default for the Action menu, so always enable it after using other options. Otherwise, your next search might not be conducted the way you want or it may appear to fail because the item was not selected. (See next tip about "sticky" options.)
• In the Options menu -
▸ The normal default is to enable "Include Headers, Footers, etc., in Find" since most users want to conduct global searches most of the time. You can disable it to conduct searches that are restricted to just the document's body text. (See next tip about "sticky" options.)
▸ To restrict a search to a section of text, just select that section before using Find and Replace. When the F&R dialog opens, use the Options menu to choose "Limit Find Within Selection".
For example, to search ONLY for items in a table:
1. Put the cursor in the table.
2. Use Edit, Select, Select Table to select that table.
3. Use Edit, Find and Replace to open the F&R dialog.
4. On the menu at the top of the dialog, use Options and enable (tick) "Limit Find Within Selection".
5. In the Find field, type or paste the item you want to find.
6. Use Find Next (etc.).
When the program has finished searching that table it will pop a "Not Found" message.
• Also see the related tips and solutions here about using macros that contain search routines: you can force them to reset Find and Replace options to their defaults before such macros finish playing.)
☼ Many Find and Replace options are "sticky" (even if only for the current session). You might need to set new options and do a find and replace to make the options take effect. Alternatively, you can play the macro here to reset these options to the factory default each time you play it (you can even assign it to the F2 key for more convenient use of Find and Replace).
☼ If you are using the default WordPerfect keyboard (i.e., the <WPWin Keyboard> in Tools, Settings, Customize, Keyboards tab), you can select a word (or just place your cursor on the word), or select a short block of text (less than 79 characters), then click Ctrl+Alt+N to jump to the next instance of that word without opening the Find and Replace dialog. Ctrl+Alt+P takes you to the previous instance. [You can also assign these features, QuickFind Next Current Word and QuickFind Previous Current Word (see under the Edit category in the Keyboard Shortcuts dialog), to the <WPDOS Keyboard>.]
☼ You can search for, and/or replace, WordPrefect symbols. [To search for format codes, see above.] When the cursor is inside either field, press Ctrl+W to choose a symbol, then click Insert and Close. If you choose <Nothing> in the Replace field, all instances of the symbol will be deleted with Replace All.
☼ You cannot use Find and Replace to find codes when they are inside certain other codes — such as inside a [Style] code (e.g., the initial [Open Style] code in a document or template) or inside text variables (a form of style). You also cannot use Find and Replace to find codes inside a [Delay] code. These are limitations of the program, at least for recent versions of it. Solution: You will have to edit the [Style] or [Delay] code by double-clicking on the code in Reveal Codes to edit it.
☼ Finding words containing hyphens: When you use Find and Replace to locate a hyphenated word or number, you must use the same type of hyphen in the Find and Replace fields as exists in the item to be searched in the document. Hence, to find a regular hyphen, the item must contain regular hyphens (i.e., codes). To find hard hyphens, the item must contain hard hyphens (which are characters, not codes).
☼ To replace multiple instances of one font type with another font type (or to delete a specific font type code): With the cursor at the very top of the document, click on Edit, Find and Replace, Type, Specific Codes, Font, OK. This opens the "Find and Replace Font" dialog. You should be able to use pull-down menus to instruct WordPerfect to replace [the first font] with [the second font] or, if desired, you can enable (tick) the box "Replace with Nothing" to delete that specific font type code. Be sure to repeat the process at least once, since it sometimes misses a few instances on the first pass.
☼ To replace multiple instances of one font size with another font size (or to delete a specific font size code): With the cursor at the very top of the document, click on Edit, Find and Replace, Type, Specific Codes, Font Size, OK. This opens the "Find and Replace Font Size" dialog. Then specify the point size to find (in the top drop list), and enable (tick) the box "Replace with Nothing" to delete that specific font size code. Finally, use the buttons of the right side of that "Find and Replace Font Size" dialog to find and replace them.
Alternatives (using macros):
▸ See the small macro on the DelCodes page here. Using a macro can be helpful if you frequently need to delete such codes in documents.
▸ See the macro Replace font size via menu.wcm by Ron Hirsch on the Other Authors page here.
☼ To replace (change) one type of text attribute (e.g., bold, underline, italics, large size, redline, etc.) with another, it is much easier to use a macro for that purpose rather than using Find and Replace. See Replace Codes.wcm in the main Library.
☼ To swap one item (e.g., "Party 1") for another item (e.g., "Party 2") throughout the document, there's a little trick on the REPLACEM macro page (here) called the A-B-C Word Triangle. Or use the REPLACEM macro to do the job with any list of text items and their replacements.
☼ To ignore (i.e., protect) certain specified items in a Find and Replace operation (here, by using a somewhat similar technique to the "swap" trick just above):
1. Use Find and Replace to convert the items you want to ignore into a short nonsense string not used elsewhere in the document (e.g., !@#$% or a string such as ABCXYZ) in order to temporarily "hide" them from the program in the next step.
2. Process the document as desired (e.g., another find/replace, an add/change format, etc.).
3. Convert the nonsense strings back into the original items by simply reversing the find/replace order of processing in step 1.
For macro writers:
One way to alert the user of a macro that searches for selected text that the selection is too long is to use something like the following snippet in the macro's code after the point where some text has been selected:
[For all users: Continued from above...]
Here's an example of using Edit, Find and Replace to add a text attribute to a word that is found anywhere in the current document. In this example it's the Redline attribute.
Obviously ... always back up the document first.
[For macros that can do this to multiple different words see the Footnote at the bottom of the ReplaceM macro page here.]
▸ In the Match menu on that F&R dialog, you can optionally choose to find Whole words, and/or have the search be Case sensitive. [NOTE: Choosing Whole Words means the program looks only for (in our example) Shakespeare and will not find Shakespeare's.]
▸ In the Action menu choose Select Match.
▸ In the Options menu you can begin the find at the top of the document, and/or include Headers and Footers.
 With the cursor in the Replace Field, click the Replace menu choice on that dialog, and choose Codes.
▸ In the Codes list that appears, scroll down to [Redln On] and choose it. Then click Insert; a code will apepar in the Replace field.
▸ Then type the word you are searching (e.g., Shakespeare).
▸ Then use the Codes button's list to insert the [Redln Off] code. Finally, close the Codes dialog list with its Close button.
 You should now have three items in the Replace field — your replacement text surrounded by a pair of On/Off format codes:
 In the Find and Replace dialog click
Replace for just the next item or click Replace All for a global
replace in that document.
contents of the Find and Replace fields later is one way of removing
any Redline you applied to just the searched words. (Just select, copy, and paste from one field to the other field.)
Another way is to search — preferably individually — for just the [Redln On] (or just the [Redln Off] code and replace it with <Nothing>. This deletes both parts of such a paired code [see Reveal Codes for more on paired codes]. The Replace Codes macro mentioned above can do this, too.
[Originally posted on WordPerfect Universe here.]