Imagine you could list the contents of a directory from a command line, and then edit the text output to make things happen. That’s sorta how Emacs
dired works. It’s kind of a cross between a bash shell and the Windows File Explorer. Why would you ever want to use such a bizarre hybrid?
One reason is to avoid context switching. If you’re editing a file, you can pop over to a new buffer that is your file manager, do what you need to do, then pop back, all without ever leaving Emacs.
Another reason is that, as with everything else in Emacs, it’s all text. Everything in Emacs is just text, and so the same editing commands can be used everywhere. (More on that here.)
Even though I use Emacs daily, and even though I can make a case for why
dired is great, I don’t use it that much. Or rather, I don’t use that much of what it can do. The good that I would, I do not.
I was reviewing
dired‘s features and discovered something very handy: typing
%& will mark files for deletion that can easily be created again. In particular, it will flag the byproducts of compiling a LaTeX file.
For example, the following is a screenshot of a
When I type
%& it highlights the LaTeX temp files in red and marks them for deletion. (The D’s in the left column indicate files to be deleted.)
This doesn’t delete the files, but it marks them for deletion. If I then type
x the files will be deleted.
In addition to the unneeded LaTeX files, it also highlighted a
.bak file. However, it did not highlight the
.o object file. I suppose the thought was that most people would manage C programs from a
make file. I’m sure the class of files to mark is configurable, like everything else in Emacs.