Jerry Ajay
Jerry Ajay

Reputation: 1094

Vim update file name

My .vimrc is configured as follows:

set laststatus=2
set statusline +=%1*\ %F  
set statusline +=%1*%=%5l%* 
set statusline +=%2*/%L%*
set statusline +=%1*%4v\ %*
set statusline +=%2*0x%04B\ %*

Whenever I save the file with a different name inside vim, I want the name of the file to reflect the new name rather than displaying the old one. What do I need to alter in-order to get this behavior ?

Upvotes: 0

Views: 192

Answers (1)

Ingo Karkat
Ingo Karkat

Reputation: 172510

The %F should get you the (full) current filename. I suspect you do the saving with :w newname. That just writes the buffer once to that new name, but keeps the original one. To rename the current buffer, use :saveas newname instead.

There's also the :file newname command to rename without writing (right now). And you can query the current name via :echo expand('%').

Upvotes: 5

Related Questions