Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rename Vim buffer, but not the content

Tags:

vim

buffer

Can you rename a vim buffer while not renaming the associated content ?

In this particular scenario, I'm running a conqueterm and want the buffer name to be the log file name that I've associated with the buffer, not the buffer name produced by conque term. More typically, this would be to rename the buffer without renaming the associated file.

like image 953
cesces Avatar asked Sep 15 '25 11:09

cesces


2 Answers

In general, no. Changing the buffer name changes the name that a file will be written to.

But for buffers that do NOT correspond to files, you can rename the buffer as you see fit. The :file command lets you do this. See :help :file_f. However, some plugins may depend on the buffer name of their special buffer to locate that buffer. So you might end up breaking the plugin if you rename the plugin's special buffers willy-nilly.

like image 61
Ben Avatar answered Sep 18 '25 04:09

Ben


I think you just want a custom, window-local 'statusline' setting. This (in its default value) includes the buffer name, but by changing the value for those windows, it'll appear with a more natural name, yet still persist (with :w etc.) to its original.

like image 20
Ingo Karkat Avatar answered Sep 18 '25 06:09

Ingo Karkat