12

I am learning Dired in Evil mode.
h j k l / are Evil keys that obviously work in Dired. Are there others?

Is there a table of Evil keys for Dired?

I am using Emacs 25.2.1 with Evil, Spacemacs, and Ivy.

Drew
  • 75,699
  • 9
  • 109
  • 225
wolfv
  • 1,403
  • 1
  • 13
  • 30
  • 2
    I encourage learning the default keybindings for `dired`, the interface is more reliable than overlaying `evil`, and `dired` is already optimized to have an efficient interface...you can automatically open `dired` in emacs state with `(add-to-list 'evil-emacs-state-modes 'dired-mode)` – Henry Jan 11 '18 at 15:02
  • The [Source code](https://github.com/emacs-evil/evil-collection/blob/98d28bc67909225a4746c557449c9da816f5d0f5/modes/dired/evil-collection-dired.el#L41-L191) obviously show a complete table – HanleyLee Jun 05 '22 at 03:22
  • @Henry I think any interface whose idea of "up" and "down" is "n" and "p" instead of home-row keys (assuming qwerty) is at best relatively/opinionatedly "optimized to have an efficient interface" (as opposed to both objectively and absolutely). – mtraceur May 06 '23 at 07:06
  • What I mean by my last comment is that: while there is some value in learning the Dired native interface, it's not necessarily the best we can do - it might be the best we can do *for users used to Emacs* (for example, `n` and `p` for down and up make more sense if you're already used to `C-n` and `C-p`), but they're not necessarily objectively the best keys for the job, and they're probably even less of a good fit for someone thoroughly trained up on vi-style motion. Dired also has some redundancy out-of-the-box (`e`, `f`, and `RET` all bound to `dired-find-file`, for example). – mtraceur May 06 '23 at 17:50

2 Answers2

11

Here are a few things you can try to see available keys:

? -- actually this is partly wrong because

SPC ? dired

F1 m (describe-mode)

SPC h SPC dired -- this lets you jump to the code for the layer that configures dired, spacemacs-base, which for key bindings purposes is mostly about keys to run dired rather than once you're using dired

Here are some dired keys I find useful (in fact nearly all are the same as in stock emacs, so you can also just read the info page with F1 i and much of it will correct key bindings still -- follow menus using m to go to Emacs -> Dired).

Note that 'marking' files lets you operate on multiple files at once when e.g. copying or moving files.

  • RET or f Open file or directory
  • o Open file in a separate window
  • ^ Up directory
  • + Create a directory
  • R Rename / move
  • C Copy
  • M Change file/directory mode (unix file/directory permissions)
  • d Delete
  • m Mark
  • u Unmark / undelete
  • x 'Expunge' -- i.e. actually delete files/directories marked for deletion
Croad Langshan
  • 3,192
  • 14
  • 42
0

I found it more helpful to approach this the other way around - what are the conflicts between Evil and Dired?

If we with Dired buffers in Evil's motion state (you can get this to be the default with (add-to-list 'evil-motion-state-modes 'dired-mode) in your config) we get a familiar, vi-like baseline.

Then we just need a list of what we "lose" - keys in Dired that are shadowed by Evil's motion keys, and what functions they are bound to:

Key Dired function Notes
B dired-do-byte-compile
e dired-find-file also bound on RET and f
f dired-find-file also bound on RET and e
F dired-do-find-marked-files
g revert-buffer
G dired-do-chgrp
h describe-mode also bound on C-h m
H dired-do-hardlink
j dired-goto-file
k dired-do-kill-lines
l dired-do-redisplay
L dired-do-load
M dired-do-chmod
n dired-next-line
N dired-man
t dired-toggle-marks
T dired-do-touch
v dired-view-file
V dired-do-run-mail
w dired-copy-filename-as-kill
W browse-url-of-dired-file
y dired-show-file-type
Y dired-do-relsymlink
! dired-do-shell-command
# dired-flag-auto-save-files
$ dired-hide-subdir
% prefix to another keymap many commands - transforming filenames, regex-involving operations, etc
^ dired-up-directory
* prefix to another keymap many commands - related to Dired's marks
( dired-hide-details-mode
- negative-argument
+ dired-create-directory
: prefix to another keymap just four GPG functions (epa-dired / "EasyPG Assistant")
? dired-summary
RET dired-find-file also bound on e and f
C-u universal-argument Evil only shadows this if configured to
C-v scroll-up-command

So with that starting point, you can just look at the standard Dired and Dired Extra documentation to learn what all the other keys do.

(Besides C-d, C-u, C-v, I didn't check modified keys for collisions between Evil motion state and Dired. I think vi/vim/Evil only use Ctrl-modified keys though, and only some of those are motions.)

mtraceur
  • 184
  • 1
  • 10