1

I'm using vim 8 with some plugins and shortcuts.

I set a shortcut for :term to open a terminal in vim:

nnoremap <F5> :wa<CR> \| :term<CR>
command Q qa

So when I type F5, a terminal will popup.

However, when I try to type :Q to close all of windows and quit vim, I get an error:

E947: Job still running in buffer "!/bin/bash"

So, I have to type <C-d> to close the terminal first, then :Q could work as expected.

I want to append some command for my command Q qa | ??? but I don't know how.

It seems that <C-w><C-c> can close the terminal, but what if I opened two or three terminals? What I need is to make my command Q to close all of windows and quit vim immediately.

3

Running process in a terminal buffer is treated mostly the same way as "an unsaved file". So you can do :qa! or :set confirm etc.etc. Well, anything to allow exit from Vim with buffers unsaved. But, of course, that will modify Vim's behaviour with respect to all buffers, not only terminals.

So if you only want to allow silent terminal closing, you should provide an extra option: :term ++kill=term. This instructs Vim to send SIGTERM to the running process if the terminal buffer needs to be closed.

| improve this answer | |

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.