| Barry MacDonnell's
Toolbox for WordPerfect
Macros, tips, and
templates for Corel® WordPerfect® for Windows®
| Page updated May 17, 2016
Main tips page | Browse tips
How to efficiently use "Find:" in the Find and Replace (F&R) dialog
Related pages -
Starting and repeating a Find operation
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 or replace the item in the document with whatever you typed into the Replace field.
You can also find and/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 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.]
If you have already searched for items they will appear in the field's
drop list. 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.
Alternatively, you can 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; or
Alternatively, you can select the items, then copy the selection to the clipboard (Ctrl+C or Ctrl+Insert), and then paste (Ctrl+V or Shift+Insert) the items (including embedded symbols or codes) from the document directly into the Find field.
useful when selecting format codes in the document:] Use Shift+Arrow to
select ("paint") the items 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 alternatives #2 and #3 will
not present a problem, but see below for more information.
Keep it short!
As with manually typing words into the F&R field, 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 is that if you pre-select text that 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 it didn't work when it often worked in the past (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, etc.). So if you copy a short selected block of text that contains these codes, these items are counted toward the 79 "character" limit when you paste them into the Find field (or let WordPerfect automatically insert them in the Find field with alternative #1 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 often-used documents can be done with text variables.]
One way to work around the truncation effect problem (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, then paste the now unformatted version into the Find field. Again, this might only be needed for sentences that approach 79 characters -- counting any embedded codes.
What about macro searches?
Note that 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 the footnote below for a code snippet to test for the length of a selected string.
☼ The Find and Replace dialog has its own menu: Type, Match, Replace, Action, Options, and Help.
• 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. [To find and replace specific font types, font sizes, or text attributes (bold, italics, etc.) see more tips below.]
• The Type menu's default is "Text" but you can also search for Word Forms or even certain Specific Codes, such as a specific left margin setting of 1.75".
• In the Match menu -
- Note that Match, "Whole Words," if left disabled (un-ticked), is the normal default for the current operation. Example: If left disabled you can find both "Word" and "WordPerfect" if you search for "Word". If you enable (tick) it you can find just "Word". (Don't assume it will be left 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 F&R dialog.)
- When the cursor is in the "Find:" field you can use the Match, "Codes" option to insert various format codes in the field by choosing them from the Codes list. [Similarly, when the cursor is in the "Replace with:" field you can use Replace, "Codes".]
To find or replace normal tabs, insert the Left Tab code.
To find or replace hard returns or page breaks, insert the HRt or HPg code, respectively.
[The Codes dialog has lots of codes so you may need to scroll down to locate the one you need (e.g., Left Tab]. An alternative is to select and copy a code from the document (in Reveal Codes) to place it into a F&R field.]
Tip: To remove individual codes or several codes at once throughout a document with a mouse click, 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 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.)
• 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 for only 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. 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:
With the cursor at the very top of the document, invoke Find and Replace. Click the "Type" menu at the top of the F&R dialog box, then click "Specific Codes." In the sub-dialog that appears, click "Font," then "OK." You should be able to use pull-down menus to instruct WP to replace [the first font] with [the second font] or, if desired, you can enable "Replace with Nothing" to delete those specific codes. 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 remove a specified font size in the document, see see the macro Replace font size via menu.wcm by Ron Hirsch on the Other Authors page here.
☼ To replace 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 Find and Replace. See Ron Hirsch's Replace Codes - Plus.
☼ 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 (e.g., another find/replace, an add/change format, etc.).
3. Convert the nonsense string back into the original items by simply reversing the order of 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: