Whenever I use the :sav
command, it saves the file with a new name and opens the new file open in Vim.
Is it possible to save the file with a new name but keep the original one open for editing?
Join Stack Overflow to learn, share knowledge, and build your career.
Whenever I use the :sav
command, it saves the file with a new name and opens the new file open in Vim.
Is it possible to save the file with a new name but keep the original one open for editing?
Use the :w
command with a filename:
:w other_filename
:w %:h/other_filename
to write to a filename in the same directory as the open file.
– loevborg
Nov 21 '13 at 13:04
:w other_filename
will write data to other_filename
only and not the current file.
– Ram Patra
Jan 3 '17 at 12:26
Thanks for the answers. Now I know that there are two ways of "SAVE AS" in Vim.
Assumed that I'm editing hello.txt.
:sav
won’t close initial buffer, it will hide it. By default, hidden buffers are unloaded, but this can be overriden (with 'hidden' or 'bufhidden' options).
– ZyX
Mar 29 '12 at 20:00
:sav[eas][!] [++opt] {file}
So, :sav
is the shortener for :saveas
. Whereas, :w
is the shortcut for :[range]w[rite][!] [++opt] {file}
. And everything is in the manual, just few lines above/below.
– Atcold
Oct 20 '14 at 19:22
After save new file press
Ctrl-6
This is shortcut to alternate file
The following command will create a copy in a new window. So you can continue see both original file and the new file.
:w {newfilename} | sp #
vim "save as"
and this question taught me that there is a:saveas
that works just like I expected: saves the existing file with a new name and opens the new file. – Jacktose Mar 29 '19 at 18:41