Search and Replace in multiple files

The Emacs tip I learned today is the search & replace in
multiple files posted by the author Atomized.

The original post is at:

It is a great post showing the perfect harmony of Emacs-integrated
tools: dired works smoothly with grep and query-replace, and Emacs can
use dired to find a list of file using “M-x find-grep-dired” according
to regular expression specified. Then with the list of files at hand,
you can use the “%-m” command of dired to do another regular expression
match. With this narrowed-down list of files, you can use the “Q”
command of dired to run query-replace on these multiple files. Emacs
will cycle through each matched file and ask you to confirm before each
replacement. In a summary,

(1) M-x find-grep-dired to generate a list of files according to a regexp
(2) %-m (from within dired) to narrow down your selected files using another regexp
(3) Q (from within dired) to start query-replace through the multiple files


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s