How to change the name of a vim buffer

buffervim

Is it possible to change the name of a buffer in vim?

Specifically, I'm using Conque Shell to open shells in vim (each shell is in a buffer) and with multiple shells, I see:

10: bash - 1
11: bash - 2

in my buffer list. I would like to rename these buffers with more meaningful names (e.g., "mercurial" instead of "bash – 2"). Is it possible?

Best Answer

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 the alternate-file name. An unlisted buffer is created to hold the old name.

Related Question