Is there a way to rename an open file in Emacs? While I'm viewing it? Something like save-as, but the original one should go away.
How to rename an open file in Emacs
emacs
Related Question
- How to control how Emacs makes backup files
- Using Emacs to recursively find and replace in text files not already open
- Emacs – Multiple columns one buffer
- Differences between Emacs and Vim
- How to have Emacs auto-refresh all buffers when files have changed on disk
- Open file via SSH and Sudo with Emacs
- Git – How to make Git use the editor of the choice for commits
- Bash – How to open Emacs inside Bash
Best Solution
Yes, with
dired
mode, you can:C-x d
to open diredRET
to select directory of current fileC-x C-j
(dired-jump
to the name of the current file, in Dired)R
to rename the file (ordired-do-rename
).q
to go back to the (renamed) file bufferThe rename is equivalent to a shell
mv
, but it will also update any open buffers, and unlikemv
it will not change the access and modify times on the file in the filesystem.