Use dired-jump
, which is bound to C-x C-j
by default to show the current file in a dired buffer. The command is part of dired-x
which is built in to emacs, but you may need to add the following to your emacs config file to activate it.
(require 'dired-x)