You can use :qa!
to force vim to exit:
:qa[ll]! Exit Vim. Any changes to buffers are lost.
Also see |:cquit|, it does the same but exits with a non-zero
value.
As :qa!
doesn't save buffer, you should use :wqa
before that.
:qa!
can be dangerous, a half-way stopped terminal might leave you garbage files.
You can also use ls R
to list running terminal buffers and load them with :b bufnr
.
Here is a command to list all running terminal buffers and modified readonly buffers in a new tab :
com ListUndead ListBuffers R =+
com -nargs=+ ListBuffers call s:list_buffers(<f-args>)
function s:list_buffers(...) abort
let bufs = {}
for flags in a:000
let l = split( execute( printf('ls! %s', flags) ), "\n" )
let l = map(l, { i,v -> matchstr(v, '\v^\s*\zs\d+') })
for buf in l
let bufs[ buf ] = buf
endfor
endfor
let first = 1
for buf in keys(bufs)
if first
exe 'tab sbuffer' buf
let first = 0
else
exe 'sbuffer' buf
endif
endfor
endfunction