query-replace is a built-in Emacs command for interactively replacing one string with another in a buffer. query-replace-regexp does the same thing, but with support for matching regular expressions. Use this tag for both commands.

By default, query-replace is bound to M-%. From the manual:

This command finds occurrences of ‘foo’ one by one, displays each occurrence and asks you whether to replace it.

query-replace-regexp is bound to C-M-% by default, and provides a similar interface, with the addition of support for regular expression matching.

Both commands are explained in the manual node (emacs) Query Replace.

history | excerpt history