How to change the name of a vim buffer
You can use :file newname
to change the buffer name.
From :help :file_f
:
Sets the current file name to
{name}
. The optional ! avoids truncating the message, as with:file
.
If the buffer did have a name, that name becomes thealternate-file
name. An unlisted buffer is created to hold the old name.
Rename the current buffer with :file <new-name>
(or :f <new-name>
):
:f[ile][!] {name}
Sets the current file name to
{name}
. The optional!
avoids truncating the message, as with:file
. If the buffer did have a name, that name becomes the alternate-file name. An unlisted buffer is created to hold the old name.
If the buffer already has a filename, :file
will not change the filename and will only change the alternate filename. You'll need to clear the name of the buffer with :0f[ile]
to be able to put one.
:e foo
:0f
:file bar