| www.delorie.com/gnu/docs/emacs/emacs_103.html | search |
![]() Buy the book! | |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
If you want to change only some of the occurrences of `foo' to
`bar', not all of them, then you cannot use an ordinary
replace-string. Instead, use M-% (query-replace).
This command finds occurrences of `foo' one by one, displays each
occurrence and asks you whether to replace it. Aside from querying,
query-replace works just like replace-string. It
preserves case, like replace-string, provided
case-replace is non-nil, as it normally is. A numeric
argument means consider only occurrences that are bounded by
word-delimiter characters.
C-M-% performs regexp search and replace (query-replace-regexp).
The characters you can type when you are shown a match for the string or regexp are:
You can type C-r at this point (see below) to alter the replaced
text. You can also type C-x u to undo the replacement; this exits
the query-replace, so if you want to do further replacement you
must use C-x ESC ESC RET to restart
(see section E.5 Repeating Minibuffer Commands).
query-replace.
Some other characters are aliases for the ones listed above: y, n and q are equivalent to SPC, DEL and RET.
Aside from this, any other character exits the query-replace,
and is then reread as part of a key sequence. Thus, if you type
C-k, it exits the query-replace and then kills to end of
line.
To restart a query-replace once it is exited, use C-x
ESC ESC, which repeats the query-replace because it
used the minibuffer to read its arguments. See section C-x ESC ESC.
See also AB.9 Transforming File Names in Dired, for Dired commands to rename, copy, or link files by replacing regexp matches in file names.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| webmaster donations bookstore | delorie software privacy |
| Copyright © 2003 by The Free Software Foundation | Updated Jun 2003 |