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.
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.
find-file
, won't trigger it.
Mar 12, 2018 at 10:28
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.
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.