vimtricks.wiki Concise Vim tricks, one at a time.

How do I suspend Vim to the background shell and return to it later?

Answer

<C-z> / :stop

Explanation

Pressing <C-z> in Vim sends it to the background of your shell session — just like suspending any Unix process. Your terminal returns to the shell prompt. Run whatever commands you need, then type fg (foreground) to bring Vim back exactly as you left it.

How it works

  • <C-z> — suspends the current Vim process and returns you to the shell (equivalent to Unix SIGTSTP)
  • :stop — the Ex command equivalent; optionally takes a ! to skip the unsaved-buffer warning
  • fg (in your shell) — brings the suspended Vim process back to the foreground
  • jobs (in your shell) — lists all suspended background jobs

Example

$ vim main.go
[editing in Vim]
<C-z>
[1]+  Stopped    vim main.go
$ git diff
$ fg
[1]+  vim main.go
[back in Vim]

Tips

  • You can suspend Vim multiple times to maintain several suspended Vim sessions. Use fg %1, fg %2, etc. to choose which one to resume.
  • This is faster than opening a terminal split inside Vim when you just need a quick shell command
  • Unlike :shell, suspending uses no extra subshell — you return to the same shell environment with all its state intact
  • :stop! bypasses the unsaved-changes warning (use with care)

Next

How do I highlight all occurrences of a yanked word without typing a search pattern?