I wish to close windows and wipe out the associated buffers with
<c-w>q but at the same time I want to prevent to quit Vim when there is only one window left.
My attempt is as follows:
vim9script def QuitWindow() # Close window and wipe buffer but prevent Vim to quit if one window is # left. if winnr('$') != 1 quit endif enddef nnoremap <c-w>q <Cmd>call QuitWindow()<cr> nnoremap <c-w><c-q> <Cmd>call QuitWindow()<cr>
QuitWindow() is correctly not recognised and I am not sure how to do for recognising a function when it is defined in
.vimrc and is not defined as global.
Perhaps this is not the right direction for achieving my goal?