2009-06-03 78 views
1

可能重复:
Using Emacs to recursively find and replace in text files not already open如何在emacs中进行大量的搜索和替换?

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

我需要向正则表达式搜索和文件的列表上取代。 是否有一个emacs命令(命令组合)? 或者,也许你有一个更好的方式来在Linux上做C++重构?

+1

看使用Emacs以递归查找和替换文本文件尚未打开(http://stackoverflow.com/questions/270930/:不然为什么不能与某些findsed魔法,一拉使用shell使用-emacs的对递归查找和替换功能于文本文件 - 不已经打开)。 – 2009-06-03 11:07:40

+1

有没有一个原因,为什么这需要在emacs而不是其他工具,如sed? – 2009-06-03 11:33:29

+2

因为在emacs中完成时一切都会更好。 – Cheeso 2009-06-03 12:11:42

回答

3

您可以在diredibuffer上标记文件并在其上查询替换regexp。

for f in $(find . -name "*.cpp"); do 
    mv $f $f.bak 
    sed -e "s/old/new/g" $f.bak > $f 
done 
相关问题