views:

218

answers:

2

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

Duplicate: using-emacs-to-recursively-find-and-replace-in-text-files-not-already-open

I need to to regexp search and replace on a list of files. Is there an emacs command (command combo) for that? Or maybe you have a better way to do c++ refactoring on linux?

+1  A: 

Have you looked into XRefactory?

Hank Gay
It seems it costs 400$
Łukasz Lew
so YOU HAVE looked into it, eh?
Cheeso
+3  A: 

You can mark files in dired or ibuffer and query-replace-regexp on them. Otherwise why not use the shell with some find and sed magic, a la:

for f in $(find . -name "*.cpp"); do
    mv $f $f.bak
    sed -e "s/old/new/g" $f.bak > $f
done
danielpoe
Seriously? you can do query-replace-regexp on marked files in dired? Good to know!
Cheeso
yes just mark the files you want to work on with `m` and then run query-replace-regexp using `Q`. Quite cool :)
danielpoe
You can also iterate over marked files in a dired buffer using dired-get-marked-files. I show an example in this blog post:http://justinsboringpage.blogspot.com/2009/04/running-elisp-function-on-each-marked.html
justinhj