19

In older emacs versions I used to type:

C-x C-f RET

And it would re-open the file currently visited in the buffer. Now (emacs 23.1.1) it opens Dired of the directory.

4 Answers 4

22

I use M-x find-alternate-file which is by default bound to C-x C-v.

This command allows to reload a file onto the current buffer, reloading the same file include - which is shown in the mini-buffer by default. This is however not as convenient if you have ido-mode enabled for buffer-switching as it will not display the current file name by default.

2
  • Other answers were excellent, too, but this answer has the fewest keystrokes.
    – Eyal
    Jan 12, 2011 at 12:51
  • This method triggers the mode hook, while Gilles' answer, find-file, won't trigger it.
    – JJPandari
    Mar 12, 2018 at 10:28
11

Are you sure you don't want to just revert the buffer?

M-x revert-buffer RET
7

You can do C-x C-f M-n RET. The behavior was changed because C-x C-f RET to reopen a file wasn't nearly as common as C-x C-f DEL RET to invoke Dired on the directory.

You can also use M-x revert-buffer to reload a file from disk, and Emacs will tell you (on most operating systems) if you try to edit a file whose copy on disk has been modified externally.

C-x C-f M-n is also useful to obtain the full path to the file in the minibuffer, so you can open a file with a similar name or copy it to the kill ring or clipboard.

2

I found a useful suggestion to go back to the previous behaviour of C-x C-f RET on help-gnu-emacs mailing list:

This hack was posted by Ted Stern:

(defun find-file-read-args (prompt mustmatch)
  (list (let ((find-file-default
           (and buffer-file-name
                (abbreviate-file-name buffer-file-name))))
      (read-file-name prompt nil find-file-default mustmatch))
    t))

I tried it out and it works well for me on emacs 23.1.1.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .