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'
  • %m
    • Mark files (regexp): .
  • M-x dired-do-query-replace-regexp
    • Query replace in marked files (regexp): @params
    • Query replace @params by: params

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”

  1. Jeff Says:
    Sweet. Better than my current sed approach.

Sorry, comments are closed for this article.