next up previous
Next: Replacing selectively Up: emacs Previous: Cutting and pasting

Searching incrementally

The incremental search is started with C-s. The search begins from the current cursor position. Start typing the string you want to find. With each keystroke, emacs searches ahead to find the next location in the text that matches all the characters you have typed so far. For example, suppose you are looking for the string those. When you type t the cursor will jump to the next t in the text. When you then type h it will jump to the next th, etc. When you have finally typed those the cursor will be positioned at the first occurrence of that word.

To find the next occurrence, hit C-s again. Each time you do, it will skip to the next occurrence in the text. At each step emacs also highlights every match on the screen, which often helps find what you are looking for.

If you continue after you have run out of text, emacs resumes from the beginning of the buffer and signals in the command minibuffer that the search is now ``overwrapped''.

Hitting the backspace key during an incremental search ``undoes'' the previous search command. That is, it causes the cursor to back up as though you had not typed the last letter or not hit the last C-s. Continuing to hit the backspace key takes you back farther.

To stop the search and keep the cursor at the new location, hit Return. To abort the search and put the cursor back where it started, hit C-g.

To search incrementally in reverse, use C-r. Everything else is the same, except that you still spell the search strings in forward order.


next up previous
Next: Replacing selectively Up: emacs Previous: Cutting and pasting
Carleton DeTar 2016-12-29