‘M-x find-grep-dired’ interactively to search and replace a regex across all files in a specified directory and subdirectories which match a pattern.
As described in this blog post, basic usage is:
M-x find-grep-dired RET catch (FooException RET
% m .php$ RET
Q catch (FooException RET catch (BarException RET
At this point, Emacs will cycle through every match in every file and ask you to confirm the replacement. If you press
!, it will replace the rest of the matches in the current file, and start prompting you for the next;
Y will replace every match in every file with no further prompting. `M-,’ restarts the interactive prompting if you break out of it.
Going back to the find-grep-dired buffer, and C-x s will save all changed files.
See DiredSearchAndReplace for more information.
See also DiredFindInLisp for