I have a vim's buffer and a terminal in the same vim's window but each time switch to terminal I can only exit it to go back to vim's buffer,

Is there a way to keep terminal session but be able to switch to vim's buffer?

I used gvim 1-10802 on windows 10.

Many thanks.

  • 1
    does the normal way not work? (see :h terminal-use) – Doktor OSwaldo May 9 '18 at 13:43
  • 1
    Thanks, that works. :h terminal-typing – Tuyen Pham May 9 '18 at 14:55

A better way which I use (and love these days) to jump between terminal (interactive mode with all alias and path set) and vim is using CTRL+Z in normal mode. Work on terminal, and when done type fg to return back to vim right where I left.

CTRL+Z Suspend Vim, like :stop. Works in Normal and in Visual mode.

1. Suspend and resume

Like most Unix programs Vim can be suspended by pressing CTRL-Z. This stops Vim and takes you back to the shell it was started in. You can then do any other commands until you are bored with them. Then bring back Vim with the "fg" command.

{any sequence of shell commands}

You are right back where you left Vim, nothing has changed. In case pressing CTRL-Z doesn't work, you can also use ":suspend". Don't forget to bring Vim back to the foreground, you would lose any changes that you made!

Only Unix has support for this. On other systems Vim will start a shell for you. This also has the functionality of being able to execute shell commands. But it's a new shell, not the one that you started Vim from. When you are running the GUI you can't go back to the shell where Vim was started. CTRL-Z will minimize the Vim window instead.

2. Starting new shell

You can start a new shell this way:

:term[inal]          //  for nvim users
:shell                // (depricated in nvim)

This is similar to using CTRL-Z to suspend Vim. The difference is that a newnshell is started. Exit back to vim hitting CTRL+D

  • Thanks, but this is for windows' terminal (cmd) and native vim's terminal. – Tuyen Pham May 12 '18 at 1:26
  • 1
    heads up :shell not an editor command in neovim 0.5 . I guess it's understandable since :term exists – 3nuc Dec 25 '20 at 11:51

From :h terminal-typing

CTRL-W can be used to navigate between windows and other CTRL-W commands, e.g.:

CTRL-W CTRL-W   move focus to the next window
CTRL-W :    enter an Ex command

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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