Using Emacs to recursively find and replace in text files not already open

As a follow-up to this question, it’s trying to find out how to do something like this which should be easy, that especially stops me from getting more used to using Emacs and instead starting up the editor I’m already familiar with. I use the example here fairly often in editing multiple files.

In Ultraedit I’d do Alt+s then p to display a dialog box with the options: Find (includes using regular expressions across multiple lines), Replace with, In Files/Types, Directory, Match Case, Match Whole Word Only, List Changed Files and Search Sub Directories. Usually I’ll first use the mouse to click-drag select the text that I want to replace.

Using only Emacs itself (on Windows XP), without calling any external utility, how to replace all foo\nbar with bar\nbaz in *.c and *.h files in some folder and all folders beneath it. Maybe Emacs is not the best tool to do this with, but how can it be done easily with a minimal command?

14 Answers
14

Leave a Comment