To invoke Dired, type C-x d (
dired). This reads a
directory's name using the minibuffer, and opens a Dired buffer
listing the files in that directory. You can also supply a wildcard
file name pattern as the minibuffer argument, in which case the Dired
buffer lists all files matching that pattern. A wildcard may appear
in the directory part as well.
C-x d ~/foo/*.el <RET> C-x d ~/foo/*/*.el <RET>
The former lists all the files with extension ‘.el’ in directory ‘foo’. The latter lists the files with extension ‘.el’ in all the subdirectories of ‘foo’.
The usual history and completion commands can be used in the minibuffer; in particular, M-n puts the name of the visited file (if any) in the minibuffer (see Minibuffer History).
You can also invoke Dired by giving C-x C-f (
a directory's name.
dired-listing-switches specifies the options to
give to ls for listing the directory; this string
must contain ‘-l’. If you use a prefix argument with the
dired command, you can specify the ls switches with the
minibuffer before you enter the directory specification. No matter
how they are specified, the ls switches can include short
options (that is, single characters) requiring no arguments, and long
options (starting with ‘--’) whose arguments are specified with
If your ls program supports the ‘--dired’ option,
Dired automatically passes it that option; this causes ls to
emit special escape sequences for certain unusual file names, without
which Dired will not be able to parse those names. The first time you
run Dired in an Emacs session, it checks whether ls supports
the ‘--dired’ option by calling it once with that option. If the
exit code is 0, Dired will subsequently use the ‘--dired’ option;
otherwise it will not. You can inhibit this check by customizing the
dired-use-ls-dired. The value
default) means to perform the check; any other non-
means to use the ‘--dired’ option; and
nil means not to
use the ‘--dired’ option.
On MS-Windows and MS-DOS systems, and also on some remote systems, Emacs emulates ls. See ls in Lisp, for options and peculiarities of this emulation.
To display the Dired buffer in another window, use C-x 4 d
dired-other-window). C-x 5 d
dired-other-frame) displays the Dired buffer in a separate
Typing q (
quit-window) buries the Dired buffer, and
deletes its window if the window was created just for that buffer.