In Dired mode, I can m mark files and R to move them to a destination.

Some times the destination path is too long. With the destination open in a split window, is there a way to move files quicker?

When I see the two dired windows on the screen, I missed the drag-and-drop function in a GUI file manager.

4 Answers 4


From the documentation:

dired-dwim-target is a variable defined in `dired.el'. Its value is nil

Documentation: If non-nil, Dired tries to guess a default target directory. This means: if there is a Dired buffer displayed in the next window, use its current directory, instead of this Dired buffer's current directory.

The target is used in the prompt for file copy, rename etc.

Put this in your init file: (setq dired-dwim-target t). Then, go to dired, split your window, split-window-vertically & go to another dired directory. When you will press C to copy, the other dir in the split pane will be default destination.


just for posterity:

there is also the handy dired-ranger package, which allows you to copy multiple sets of files to a clipboard, navigate to a target destination and copy or move them there. it also cooperates with the dired-dwim-target mentioned in the other answer.

it doesn't provide keybindings out of the box, you have to set them up yourself. you can do this with some thing like:

(eval-after-load "dired" '(progn
    (define-key dired-mode-map (kbd "C-x w") 'dired-ranger-copy)
    (define-key dired-mode-map (kbd "C-x x") 'dired-ranger-move)
    (define-key dired-mode-map (kbd "C-x y") 'dired-ranger-paste)

(use C-h c from dired to see what keybindings are undefined.)

it is available from melpa.

a brief description: http://pragmaticemacs.com/emacs/copy-and-paste-files-with-dired-ranger/.


A directory that is visited by a Dired buffer in another window is by default included in the "future history" of the minibuffer that is used for file name completion; when prompted for the destination of the rename operation, use M-n (and M-p) to move through the minibuffer history until you reach the item corresponding to the directory in the other open Dired buffer.

In your case, with only one other Dired buffer open and assuming no other customizations, typing M-n once should yield the desired destination.

It is pointed out by another answer and in Minibuffer History (GNU Emacs Manual) that:

You can customize dired-dwim-target to prefer either the next window with a Dired buffer, or the most recently used window with a Dired buffer, or to use any other function.

That is, however, not necessary for getting quick access to the desired directory, thanks to the "future history" of the minibuffer as we saw above. Still, it may be useful should you find yourself having to type M-n more often than not in that situation.

  • 1
    When I start Emacs 28.2 with --no-init-file and say C-x C-f /tmp/A, C-x 2, M-: (dired "/tmp/B"), followed by R with point on . and then press M-n, the minibuffer is populated with /tmp/A from the "future history", i.e. the directory visited by the Dired buffer in the other window. The directories /tmp/A and /tmp/B existed prior to starting Emacs. Do you observe a different behavior? If not, could you please elaborate on how it is inconsistent with the quoted statement?
    – joelpet
    Commented Dec 18, 2022 at 21:43
  • I revised my test: Start Emacs 28.2 with --no-init-file and type (dired "/tmp/A")(dired "/tmp/B") into the scratch buffer, say M-x eval-buffer, C-x 2, and M-x previous-buffer. The two directories are now visible in Dired buffers – neither has been entered in the minibuffer. Move point to . in /tmp/A and say R. Then, in the minibuffer, say M-n to have it populated with /tmp/B from the "future history".
    – joelpet
    Commented Dec 19, 2022 at 10:52
  • I see now that you said "future history", not "history". That was formerly (more correctly) called a sequence of "default values". It depends in Dired (e.g. R) on a few things, including dired-dwim-target. I deleted my comment; thx.
    – Drew
    Commented Dec 19, 2022 at 15:56

% m is the command for dired-mark-files-regexp.

In addtion to @Nsukami _'s answer, if your target files shows a certain pattern, 'regex mark' might help boost the process.

  • 1
    Please say something in your answer about copying/moving, which is what the question asks. This doesn't seem to answer the question - this just tells us of a way to mark files (and there are many such ways). The OP clearly knows about marking, but wants to know about copying/moving the files that are marked.
    – Drew
    Commented Nov 6, 2020 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.