Next: Advanced Mark Commands, Previous: Shell Command Guessing, Up: Top [Contents][Index]

## 6 Virtual Dired

Using Virtual Dired means putting a buffer with Dired-like contents in Dired mode. The files described by the buffer contents need not actually exist. This is useful if you want to peruse an ‘`ls -lR`’ output file, for example one you got from an FTP server. You can use all motion commands usually available in Dired. You can also use it to save a Dired buffer in a file and resume it in a later session.

Type `M-x dired-virtual` to put the current buffer into virtual Dired mode. You will be prompted for the top level directory of this buffer, with a default value guessed from the buffer contents. To convert the virtual to a real Dired buffer again, type `g` (which calls `dired-virtual-revert`) in the virtual Dired buffer and answer ‘`y`’. You don’t have to do this, though: you can relist single subdirectories using `l` (`dired-do-redisplay`) on the subdirectory headerline, leaving the buffer in virtual Dired mode all the time.

The function ‘`dired-virtual-mode`’ is specially designed to turn on virtual Dired mode from the `auto-mode-alist`. To edit all `*.dired` files automatically in virtual Dired mode, put this into your `~/.emacs`:

    (setq auto-mode-alist (cons '("[^/]\\.dired$" . dired-virtual-mode)
                                  auto-mode-alist))

The regexp is a bit more complicated than usual to exclude `.dired` local-variable files.