In nvim how can I come out of the terminal mode without closing the nvim overall?!

In Vim I just do :!python script.py, when I'm done reading the output I can hit enter to come out of the python shell.

In nvim I do now :terminal python script.py, I am directed to the python shell output, and there is no way to get back to my script. :q of course closes nvim.

This is feeling horrible in comparison how easy it was done in Vim!

  • Does NeoVim's :terminal replace the buffer in the current window? That's a bit odd, to me, since Vim's :terminal splits the window first. So C-w c or similar only closes the new window.
    – D. Ben Knoble
    Commented Feb 12, 2023 at 15:36

1 Answer 1


To switch back to your script you can do: :b#

More information about the :b command with :help :buffer. The # stand for the previously edited buffer. You can list all the buffers and get their name and shortcut with the :ls command.

If your stuck into the terminal mode (which I undestood you are not) you should type: Ctrl-/Ctrl-n

To make it more easy you can introduce a terminal mapping into your .vimrc file.. e.g. to Ctrl-q:

tnoremap <C-q> <C-/><C-n>
  • 1
    And could you please tell me where I can read about the :b#, I didn't find anything listed under :help :terminal.
    – Student
    Commented Feb 11, 2023 at 17:26
  • Welcome to Vim :-. Thanks for the feedback. I have edited the answer accordingly. If the solution solves your problem you could validate it using the v button next to the arrow voting buttons ;-) Commented Feb 12, 2023 at 6:56

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.