RED Find and Replace

Five functions exist to find and replace text. They are: find, find-backward, find-next, find-next-reverse and replace. Find, find-backward and replace open dialog boxes to let you specify what to search for (and what to replace it with). The find-next functions can be used for two things: to repeat the last find operation or to find the next occurrence of a string visible on your screen. This will be explained in more detail in the next section.

Finding Text

If you have the text on the screen...

Often you want to find a string that you currently see on the screen (e.g. you see a procedure call and you want to find the procedure definition, or you see a variable and you wonder where else this variable is used).

A quick way exists to perform this find operation: the find-next function. (Follow this link to see how to call this function.) If a selection is on, find-next searches for the next occurrence of the selected text. Thus, to find the next use of a variable, do the following:

Find-next uses the same find parameters (search direction: forward or backward, case sensitive or not, whole word only or not) as the last find operation (specified in the find dialog). The default (if you have not used find yet) is forward, case insensitive, not only whole words.

You can reverse the search direction by calling find-next-reverse instead. If, for instance, the current search direction is forward, find-next-reverse will search for the current selection backwards.

Wrapping around

If you perform a find operation (e.g. forward) and the search string can not be found between the cursor position and the end of the text, Red notifies you with a message in the information area. If you then call find-next again, it wraps around to the beginning of the text and continues the search there (it notifies you of doing this with a message in the information area). The same principle applies when searching backwards.

If you don't have the text on the screen...

If you want to search for a piece of text that you do not currently see on the screen (so you can not select it and call find-next), you use the find function. The default key binding for find is Alt-f. Find opens a dialog and lets you specify the find details. See the entry for find in the function list for an explanation of the details.

The function find-backward performs the same operation. The only difference is that the "Find Backward" button in the dialog is the default button. So typing the search string and "Return" will search backwards.

Quick find

Red offers another find function, named quick-find, for faster searching, by default bound to Ctrl-f. (For Emacs users: this function is modelled on the Emacs "I-search" function.) Sometimes it is annoying to open a dialog window, especially on systems that require you to then position the mouse pointer inside that dialog to enter text. quick-find is a find function that offers less options but works without opening a separate dialog. The search string is entered in the information area at the bottom of the edit window, and the search is executed as you type. Most of the time, you don't have to type the whole word you are looking for - you can see it as soon as your search string identifies it uniquely.

While using quick-find, calling it again (i.e. pressing Ctrl-f again) searches for the next occurence of the same string. If the end of the buffer is reached, calling quick-find again wraps around and continues the search at the start of the buffer. quick-find always searches down from the cursor position and ignores case.

While in quick-find mode (while the search string is entered), invoking any function other that typing printable characters or calling quick-find leaves the find mode and reverts to normal editing. (You can, for example, just move the cursor to terminate the search.)

Replacing Text

To replace text, call the function replace (via menu, tool bar or keys). The default key binding is Alt-r. The function opens a dialog box to specify the replace details. See replace for a detailed description of the options.
Main index