If I am exploring my file system in Dired-mode and I come across a video file, for example, it would be nice to be able to play that video file. How can I do this in Emacs?

I can use Emacs to open a video file, but the result is not very useful - I just get the encoded file displayed as text. Is there a way the Emacs can play video files, or perhaps link it to a command that has another program like vlc play the file?


On Linux I do this all the time. While in dired mode, have the cursor on the file you want to watch.

Type !, followed by the program you want to use.

I use mplayer, so I type:


And that's it. You could just as well use vlc, or whatever works on your platform:


What's really good, using dired, is that I get a window with the mplayer output (which I don't get if, with a file editor such as nautilus or thunar, I right click and request the file to be stared with mplayer).

Anyway, no need of any macros or extensions. Just ... !

  • use & to do it asyncly, eg: &vlc - you'll get your emacs back without needing to close the shell command – Darshan Chaudhary Apr 27 '17 at 16:55

Dired+ helps with this, but even vanilla Dired offers the basics of what you need.

This answer tells you how, in detail. It explains how to use any external program to access any file, even though the question it replies to is only about using an external PDF viewer to view PDF files.

The answer also depends to some extent on what platform you use. In particular, if you use MS Windows then you can take advantage of Windows file associations etc.


I've described my VLC setup in this post. What's really cool about it is that the child process is disowned through nohup, so you can safely restart or close Emacs without having VLC automatically close.

Here's the code:

(require 'dired-aux)
(defvar dired-filelist-cmd
  '(("vlc" "-L")))
(defun dired-start-process (cmd &optional file-list)
   (let ((files (dired-get-marked-files
                 t current-prefix-arg)))
      (dired-read-shell-command "& on %s: "
                                current-prefix-arg files)
  (let (list-switch)
     cmd nil shell-file-name
      "nohup 1>/dev/null 2>/dev/null %s \"%s\""
      (if (and (> (length file-list) 1)
               (setq list-switch
                     (cadr (assoc cmd dired-filelist-cmd))))
          (format "%s %s" cmd list-switch)
      (mapconcat #'expand-file-name file-list "\" \"")))))

(define-key dired-mode-map "r" 'dired-start-process)

Another thing the code does is that it allows to mark several files with m, and then queue all of them to a VLC playlist.


The following snippet will work on an OSX operating system for just one file where the cursor is currently at -- the code does not provide for examining the file extension and/or guessing the correct application that matches the file extension:

  "my-process-name" ;; process name
  nil ;; buffer output name, if an output buffer is so desired.
  "open" ;; argument 1
  "-a" ;; argument 2
  "/Applications/VLC.app/Contents/MacOS/VLC" ;; argument 3
  (dired-get-file-for-visit)) ;; argument 4

If the original poster wants to deal with opening multiple marked files, then use dired-get-marked-files and mapcar down the list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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