O'Reilly logo

Learning GNU Emacs, Second Edition by Eric S. Raymond, Bill Rosenblatt, Debra Cameron

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Working with Files and Directories

Dired, the directory editing mode, is one of the most interesting features of Emacs. It provides a way of editing a directory. You can look at a listing of all the files in a directory, delete them, rename them, copy them, and perform almost all basic file operations. Once you have gotten used to Dired, you never need the UNIX cp, rm, or mv commands. More important, Dired can make you more productive. For example, you can work with groups of files, deleting, moving, compressing, or even query-replacing strings in them.

There are several ways to start directory editing. If you’re not in Emacs, invoke Emacs with a directory name as an argument, for example:

% emacs fiction

Emacs starts up editing the directory fiction: you’ll see a single window, which contains a listing of the fiction directory. You can also start the directory editor by using C-x C-f (or any other command for visiting a file) and naming a directory, rather than a plain file. For example, typing C-x C-f fiction gets you ready to edit the fiction directory. Typing C-x d (for dired) or selecting Open Directory from the Files menu also starts Dired; you then specify a directory name. No matter how you start the editor, the result is the same.

Type: C-x C-f fiction RETURN

Working with Files and Directories

You now see a basic directory editor display.

As you can see, Dired’s display is similar to what you see when you ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required