When editing a file named oldFile, with the command
:saveas newFileName I expected vim to save the current buffer under the new named file (i.e. newFileName) and set the filename of the current buffer to the new named file. However the current buffer still refers to the old file name (i.e. oldFile). I had to close vim and reopen the new named file from the command line.
Why does renaming a file with
:saveas newFileName continue saving changes to the old filename instead of the new filename?
Is there a single command to save the current buffer under the name of a new file and set the filename of the current buffer to the new file?
I tested the command
:saveas again and it works as expected, that it is,
:saveas newFile saves the current buffer as newFile, then renames the current buffer as newFile. I also found that another way to save a file as a different name and open the different named file is to (1) rename the current buffer
:f newFile (2) save the renamed current buffer (3) optionally delete the old file by executing a shell command in vim
!rm oldFile. I assume human error was the cause of the initial problem with the command