The Editor provides a wide range of facilities to search for and replace text. The examples below introduce you to the basic principles; please refer to the LispWorks Editor User Guide for a complete description of the facilities available.
The simplest way of searching for text in a buffer is to use the commands available in the menu bar:
Figure 13.15 Use of the Find dialog in the Editor
The cursor is placed immediately after the next occurrence in the current buffer of the string you specified. To search the buffer from the start, rather than the current point, check From Top and click Find Next . To search upwards, select Up in the Direction panel and click Find Next . To search again for a string that you previously searched for, select the string from the Find what list and click Find Next .
To dismiss the Find dialog, click Cancel .
After you have used the Find dialog, you can use Edit > Find Next to find the next occurrence of the last string for which you searched using the dialog, without raising the dialog again.
Press
Ctrl+S
to perform an
incremental search
(in which every character you type further refines the search). A prompt appears in the echo area, asking you to type a string to search for. As soon as you start typing, the search commences.
Consider the following example: open the file examples/capi/applications/othello.lisp
. You want to search for the word "defmethod" in the buffer.
Ctrl+S
The following prompt appears in the echo area.
I-Search:
d
.The prompt in the echo area changes to
I-Search:
d
The cursor moves to the first occurrence of "d" after its current position.
e
.The prompt in the echo area changes to
I-Search:
de
The cursor moves to the first occurrence of "de".
f
.The prompt in the echo area changes to
I-Search:
def
The cursor moves to the first occurrence of "def".
This continues until you stop typing, or until the Editor fails to find the string you have typed in the current buffer. If at any point this does occur, the prompt in the echo area changes to reflect this. For instance, if your file contains the word "defun" but no word beginning "defm", the prompt changes to
Failing I-Search:
defm
You can search for text and replace it with other text using the Edit > Replace... menu item. Type a string to search for and a string to replace it with in the Replace dialog that appears, and click Find Next . The cursor is placed immediately after the next occurrence in the current buffer of the string you specified. To replace this occurrence and locate the next one, click Replace . To leave this occurrence as it is and locate the next one, click Find Next . Note that this type of searching is not incremental.
For instance, assume you wanted to replace every occurrence of "equal" to "equalp".
equal
in the
Find what
box:equalp
in the
Replace with
box and click
Find Next
.The search will stop at every occurrence of "equal" after the current cursor position:
Note: Both Edit > Find... and Edit > Replace... start searching from the current position in the buffer. When the end of the buffer is reached, you are asked whether to start again at the beginning. To start from the top of the buffer initially, check the From Top option before searching.
LispWorks IDE User Guide (Unix version) - 12 Feb 2015