A few weeks ago I wrote an article called “Delete file and buffer”. Today we’ll revisit the article in a way, by exploring a pretty similar topic - renaming of a file and its associated buffer. I’ve taken the liberty to use pretty much the same wording I used in the aforementioned post to spare me the effort of thinking up something original.
From time to time(most often when I refactor code) I need to
dired from the equation) rename a file and
the buffer associated with it. Since most of the files I work with
are under version control I can just use the tried and true
vc-rename-file. Unfortunately the command does not act on the current
file and will prompt you for a file to rename. Looks like we need to
create a simple wrapper around it to get the job done:
1 2 3 4 5 6 7 8 9 10 11 12
The wrapper is extra smart and will work on files that are not under
version control as well! I’m pretty fond of commands that do what you
mean instead of throwing errors. Now that we have this neat little
command we should probably bind it to some each to press keys, like
As usual both the command and its keybinding are available in Prelude.