Some time ago I wrote about a few nice Dired features. Recently, I decided to look at the Dired chapter of the Emacs manual, and I discovered even more of them.
For instance, a few months ago Oleh Krehel wrote about his ediff/Dired setup. I liked it a lot, and I copied his code (with one small change: I changed ediff to plain diff, which I prefer due to its simplicity). It turned out, however, that Dired has a very similar thing built in. Many of you may know that if you put point on a “new” file in Dired and press =
(the “equals” sign), Emacs will ask for the “old” file and perform a diff between them. It is perhaps less known that if the pointed file has a backup, it will be used as the default “old” file. Even better, if you have active region, then the file the mark is on will be the default suggestion for the “old” file. It is still less convenient than Oleh’s solution, but it’s there.
Another nice thing I learned are the dired-do-isearch
and dired-do-isearch-regexp
commands, bound to M-s a C-s
and M-s a
M-C-s
. They do exactly what they say on the tin: you mark several files (using one of the many marking commands in Dired), and then perform an isearch (string- or regex-based) on all these files. You can also do a non-incremental regex search on marked files (dired-do-find-regexp
, A
) or even a multi-file regex query-replace (dired-do-find-regexp-and-replace
, Q
).
If you think that’s all Dired can do, well, I barely scratched the surface. There’s a lot more than that. (Check out dired-maybe-insert-subdir
, i
, and the wole sections on subdirectories for a powerful set of commands letting you put more than one directory in a Dired buffer at the same time, for instance!) I really encourage you to read through the Dired chapter in the Emacs manual – it won’t take more than 20 minutes, and it may save you a lot of time later.
Happy direding.