Next: Repeat Isearch, Up: Incremental Search [Contents][Index]

#### 15.1.1 Basics of Incremental Search

`C-s`

  Begin incremental search (`isearch-forward`).

`C-r`

  Begin reverse incremental search (`isearch-backward`).

`C-s` (`isearch-forward`) starts a forward incremental search. It reads characters from the keyboard, and moves point just past the end of the next occurrence of those characters in the buffer.

For instance, if you type `C-s` and then `F`, that puts the cursor after the first ‘`F`’ that occurs in the buffer after the starting point. If you then type `O`, the cursor moves to just after the first ‘`FO`’; the ‘`F`’ in that ‘`FO`’ might not be the first ‘`F`’ previously found. After another `O`, the cursor moves to just after the first ‘`FOO`’.

At each step, Emacs highlights the current match—the buffer text that matches the search string—using the `isearch` face (see Faces). See Search Customizations, for various options that customize this highlighting. The current search string is also displayed in the echo area.

If you make a mistake typing the search string, type `DEL`. Each `DEL` cancels the last character of the search string. See Error in Isearch, for more about dealing with unsuccessful search.

When you are satisfied with the place you have reached, type `RET`. This stops searching, leaving the cursor where the search brought it. Also, any command not specially meaningful in searches stops the searching and is then executed. Thus, typing `C-a` exits the search and then moves to the beginning of the line; typing one of the arrow keys exits the search and performs the respective movement command; etc. `RET` is necessary only if the next command you want to type is a printing character, `DEL`, `RET`, or another character that is special within searches (`C-q`, `C-w`, `C-r`, `C-s`, `C-y`, `M-y`, `M-r`, `M-c`, `M-e`, and some others described below). You can fine-tune the commands that exit the search; see Not Exiting Isearch.

As a special exception, entering `RET` when the search string is empty launches nonincremental search (see Nonincremental Search). (This can be customized; see Search Customizations.)

To abandon the search and return to the place where you started, type `ESC ESC ESC` (`isearch-cancel`) or `C-g C-g` (`isearch-abort`).

When you exit the incremental search, it adds the original value of point to the mark ring, without activating the mark; you can thus use `C-u C-SPC` or `C-x C-x` to return to where you were before beginning the search. See Mark Ring. (Emacs only does this if the mark was not already active; if the mark was active when you started the search, both `C-u C-SPC` and `C-x C-x` will go to the mark.)

To search backwards, use `C-r` (`isearch-backward`) instead of `C-s` to start the search. A backward search finds matches that end before the starting point, just as a forward search finds matches that begin after it.

Next: Repeat Isearch, Up: Incremental Search [Contents][Index]