Search code examples
emacsdired

In Emacs dired, how to find/visit multiple files?


If I have multiple files marked, how do I find/visit all those marked files in emacs, beside running dired-find-file on each of them?

Is there a build-in command, or do I need some extra lisp code?


Solution

  • If you add this to your .emacs, you'll be able to open the files via the keybinding 'F'.

    (eval-after-load "dired"
      '(progn
         (define-key dired-mode-map "F" 'my-dired-find-file)
         (defun my-dired-find-file (&optional arg)
           "Open each of the marked files, or the file under the point, or when prefix arg, the next N files "
           (interactive "P")
           (let* ((fn-list (dired-get-marked-files nil arg)))
             (mapc 'find-file fn-list)))))
    

    Obviously you can just override the built-in 'f' if you want.