I am currently editing one file and, after finishing its edit, I want to close the current file and at the same time (i.e., without closing Vim) open another file for editing.
How it can be achieved?
Vi and Vim Stack Exchange is a question and answer site for people using the vi and Vim families of text editors. It only takes a minute to sign up.
Sign up to join this communityI don't think this can be done using a single command. You'll have to use a combination of commands:
As statox suggested, delete the current buffer and open a new one:
:bd | e filename
Or rename the current file and edit it:
:file filename | e
Use :w | bd | e filename
or :w | file filename | e
to save the current file and start on a new one.
You can, of course, use maps or custom commands to simplify this:
:command -nargs=+ WE w | bd | e <args>
Then do:
:WE new-filename
:e filename
(or:we filename
if you also want to write the previous file) ? (Or maybe I'm misunderstanding you):buffers
will show you.:bd
to close the current buffer and:e filename
to open a new one.