tags:

views:

492

answers:

5

Hi,

How could I exit Vim, not :q, and then go back to continue edition.

Thanks.

+3  A: 

You can switch to shell mode temporarily by:

:! <command>

such as

:! ls
Jay Zeng
+2  A: 

If you are on a unix system, ctrl-Z will suspend vim and give you a shell. Type fg to go back. Note that vim creates a swap file while editing, and suspending vim wouldn't delete that file (you aren't exiting vim after all). On dumb terminals, this method was pretty standard for edit-compile-edit cycles using vi. I just found out that for me, gvim minimizes on typing ctrl-Z.

Alok
+12  A: 

Assuming terminal vim on a flavor of *nix:

To suspend your running vim

control-z

will suspend the process and get back to your shell

fg

will resume (bring to fore**g**round) your suspended vim

To start a new shell

start a subshell using:

:sh

(as configured by)

:set shell?

or

:!bash

followed by:

control-d  (or exit, but why type so much?)

to kill the shell and return to vim

zen
Way to steal my answer :)
Pierre-Antoine LaFayette
+1  A: 

There are several ways to exit vim and have every thing the same when you return. There is very good documentation within vim itself explaining the various ways this can be done. You can use the following command within vim to access the relevant help page: :help usr_21

To give you a brief summary, here are the different methods of quitting and returning with your session intact:

  1. Suspend and resume - You don't actually quit vim with this, you simply hide your session in the background until you need it. If you reset your computer or issue a kill command to vim, you will lose your session. This is good for when you want to switch to another task temporarily, but if this is the case, then you might want to look into using the GNU Screen utility instead.

  2. Sessions - This is the true way of saving your session between instances of vim. Even if you truly quit vim, your session will be there for you when you return. This is probably what you are looking for.

Swiss
+9  A: 

You can use :sh to exit to your default shell then typing $ exit at the shell prompt will return you to vim.

Pierre-Antoine LaFayette
I wish I could upvote this harder. This is exactly why :shell exists.
Randy Morris