Emacs find/replace across directories

July 13th, 2008
M-x find-dired [Enter]

(make sure it’s in the right directory) [Enter]

-name '*.rb' [Enter]

% m rb$ [Enter] (or just mark individual ones with ‘m’)

M-x dired-do-query-replace-regexp [Enter]

regexp-to-search-for [Enter]

string-to-replace-with [Enter]

Then don’t forget to save.

Or there’s M-x tags-query-replace if you have TAGS set up. If you use speedbar (I don’t), I think it provides a way to do it with more of a notion of a “project” than just a directory.

Found here