All Manuals > LispWorks IDE User Guide > 13 The Editor

NextPrevUpTopContentsIndex

13.12 Searching and replacing text

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.

13.12.1 Searching for text

The simplest way of searching for text in a buffer is to use the commands available in the menu bar:

  1. Choose Edit > Find... to search for text in the current buffer.
  2. Type a string to search for in the dialog that appears.
  3. Click the Find Next button.

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.

13.12.2 Incremental searches

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.

  1. Press Ctrl+S
  2. The following prompt appears in the echo area.

    I-Search:
  3. Type the letter d.
  4. The prompt in the echo area changes to

    I-Search: d

    The cursor moves to the first occurrence of "d" after its current position.

  5. Type the letter e.
  6. The prompt in the echo area changes to

    I-Search: de

    The cursor moves to the first occurrence of "de".

  7. Type the letter 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

as soon as you type m.

13.12.3 Replacing text

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".

  1. Choose Edit > Replace... .
  2. The Replace dialog appears.

  3. Type equal in the Find what box:
  4. Type 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

NextPrevUpTopContentsIndex