How to temporarily exit Vim and go back
How could I exit Vim, not :q
, and then go back to continue editing?
Solution 1:
Assuming terminal Vim on a flavor of *nix:
To suspend your running Vim
Ctrl + Z
will suspend the process and get back to your shell
fg
will resume (bring to foreground) your suspended Vim.
To start a new shell
Start a subshell using:
:sh
(as configured by)
:set shell?
or
:!bash
followed by:
Ctrl+D (or exit
, but why type so much?)
to kill the shell and return to Vim.
Solution 2:
You can use :sh
to exit to your default shell then typing $ exit
at the shell prompt will return you to Vim.
Solution 3:
You can switch to shell mode temporarily by:
:! <command>
such as
:! ls
Solution 4:
You can also do that by :sus
to fall into shell and back by fg
.
If you frequently need to go back and forth between shell and vim, probably what you really want is have only one vim instance in the shell, and use it to open any file in the workspace. If so, check this question. Once you set it up correctly, you can :sus
or C-z
to return to the shell, then just v
or v <newfile>
to get back to vim.
And my answer is almost my daily routine.