Fun with Emacs
February 19th, 2008
One good part of doing a big refactoring is that I get to have fun with emacs.
I found a great step by step tutorial with all the details. But basically, first you get in to dired (directory editing), then mark the files you want to search through, and then do dired-do-query-replace-regexp.
So for example, to replace @params with params in all controllers:
M-x find-dired- Run find in directory:
app/controllers - Run find (with args):
-name '*.rb'
- Run find in directory:
%m- Mark files (regexp):
.
- Mark files (regexp):
M-x dired-do-query-replace-regexp- Query replace in marked files (regexp):
@params - Query replace @params by:
params
- Query replace in marked files (regexp):
Dired is fun stuff like emacs’s other “everything is a buffer!!” things (just like unix’s “everything is a file!!”). I’m not quite emacs-hacker enough to use it as a shell for extended periods of time though.
1 Response to “Fun with Emacs”
Sorry, comments are closed for this article.
March 8th, 2008 at 09:07 AM Sweet. Better than my current sed approach.