Is there a way to move a file within Vim? E.g. I opened a file foo/bar.txt in Vim. I know 2 ways to move this file:
First solution:
- Delete the buffer with
:bd bar.txt - Perform the move on the shell with
mv foo/bar.txt foo/bar2.txt - Load the file in vim with
:e foo/bar2.txt
Second solution:
- Close Vim, so all buffer where closed.
- Perform the move on the shell…
- Start Vim and load the file.
But these two solutions are embarrassing. I know, there is a plugin for renaming files vim-enuch, but isn’t there a Vim way for performing such basic functionality?
There is no atomic way to move a file like that, but this should be close:
Now you could say:
To rename to file2.txt
to move file2.txt to file2.txt.0