Next / Previous / Contents / TCC Help System / NM Tech homepage

7. Search and destroy

7.1. Incremental search

C-sStart forward incremental search.
C-rStart reverse incremental search.

When you are searching incrementally, each regular character you type becomes part of the string you're searching for. For example, C-s r moves the cursor to the next r; typing a moves the cursor to the next occurrence of the string ra; and so forth.

These characters have special meaning in incremental search mode:

enterStop searching and the leave the cursor where it is.
C-gStop searching and move back to where the cursor was when you started searching.

If you want to type the entire search string before asking emacs to find it, type C-s enter. You will be prompted for the search string, and when you press enter the second time, the search will be executed. Non-incremental reverse search works the same way, by typing C-r enter.

7.2. Query replace

To replace all occurrences of some old string with a different string, type M-%. You will prompted for the old string with the prompt Query replace:; type the old string and then press enter. You'll then be prompted for the new string; type it and again press enter.

At that time, if there are any occurrences of the old string in your file, the cursor will jump to the first occurrence. At that point you can type any of these characters:

spaceReplace this one, then continue replacing.
delDon't replace this one, but continue.
escStop, don't replace any more, any leave the cursor where it is.
,Replace this one, but let me see the new text in place before going on. Type space when you are ready to go on.
.Replace this one, then stop.
!Replace all the rest of the old strings without asking.