Go to the first, previous, next, last section, table of contents.


Query Replace

The query-replace function provides an interactive method of replacing strings in a buffer which match a specific regular expression.

For each occurrence found you, the user, have a number of options; for example, you could replace this occurrence with a prespecified template.

Meta-% regexp RET template RET
Invoke a query-replace, for all occurrences of the regular expression, regexp you will be prompted for what you want to do with it. Usually this will be to replace it with the expansion provided by the template (see see section Regular Expressions) template.

Special commands which come into effect each time the query-replace finds a match are,

SPC
y
Replace this occurrence with the expansion of template and search for the next match.
Backspace
n
Ignore this match and search for the next.
,
Replace this occurrence, then wait for another command.
RET
ESC
q
Exit this query-replace.
.
Replace this occurrence then exit.
!
Replace the current match and all the rest between here and the end of the buffer.
^
Retrace your steps through each match which has been found.
Ctrl-r
Enter a recursive-edit, this is allows you to edit this match by hand. When you exit the recursive-edit (with the Ctrl-Meta-c command) the next match is searched for.
Ctrl-w
Delete the current match, then enter a recursive-edit, as in the Ctrl-r command.


Go to the first, previous, next, last section, table of contents.