In vim, I might have 3 or 4 files I am viewing at the same time. On such occasions, I will need to close all files individually and return back to the command line so I can do something else.
I'd like to be able to do that quickly and not have to do a :wq
in all open windows. Basically a shortcut to close NERDTree and other buffers together.
3 Answers
Use Ctrl + z to go back to command line. Then you can
fg 1
to go back to where you were.
-
1I found that after closing all windows and doing command line stuff I would have to reopen them all back up again. Your solution makes that easy. Mar 22, 2016 at 11:29
To return back to command line, simply use
:qa " as in quit all
To save all files, use :wqa
.
To close all windows(splits) except current one, use ctrl+w o (C-w o
)
Inorder to close all buffers except current one, there is a script BufOnly
-
This solution works, however Xavitoj's solution is a little more beneficial. Mar 22, 2016 at 11:27
Since Isaac's comment makes clear the question is actually about how to return to the command line and then return to Vim:
To open a shell when inside Vim, use the command :sh
or :shell
. From the docs:
:sh[ell]
This command starts a shell. When the shell exits (after the "exit" command) you return to Vim. The name for the shell command comes from 'shell' option.
Also see the two following commands:
:!{cmd}
Execute
{cmd}
with the shell.
:!!
Repeat last
:!{cmd}
.