I just learned that Vim has the :terminal command, which opens a window with a terminal session inside. Previously, my normal workflow was to launch vim from my terminal and use job control to get in and out of it (i.e. edit files, use <C-z> to put vim in the background, interact with my shell, then use fg to bring vim back to the foreground, then keep editing files).

Now that I know about :term, it would be nice to incorporate it into my workflow. However, I require the ability to still be able to use the workflow mentioned above. The problem is, <C-z> inside the terminal window inside vim gets interpreted by that window's shell. According to :help terminal-typing, using <C-w> N will enter Terminal-Normal mode. From there I can use <C-z> like I am used to doing. However, after I get back into vim, the terminal is still in Terminal-Normal mode, and I need to manually enter Terminal mode (using i or a or whatever).

Is there a way to send vim to the background from within a terminal window in such a way that leaves the terminal in Terminal mode? I'd like to set up some mappings such that I can treat the terminal window splits just like other vim windows seamlessly.

1 Answer 1


You can use Ctrl+W, : to enter Ex mode from the terminal, then use the :suspend command to suspend Vim (same as Ctrl+Z typically does.)

When you come back to Vim using fg, you'll be on your Vim terminal, which will be already in insert mode (since Ctrl+W, : only enters Ex mode for a single command.)

If you want to map Ctrl+Z in the terminal to suspend Vim (instead of suspending whatever foreground program the shell in the terminal is running), you can add the following mapping to your vimrc:

tnoremap <C-z> <C-w>:suspend<CR>

That way, Ctrl+Z on a terminal will behave the same as it behaves in a normal Vim buffer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.