2

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?

update

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 :saveas

closed as off-topic by klaus, Herb Wolfe, Martin Tournoij Apr 23 at 0:37

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers." – klaus, Herb Wolfe, Martin Tournoij
If this question can be reworded to fit the rules in the help center, please edit the question.