I'm writing a script that creates a window that I'd like to be completely transient, like a help window. Specifically, if the user closes every window but this one, I want Vim to quit. (In the same way that if you have a single window open with no unsaved files, then the string of commands:
:quit, will cause Vim to quit.)
I'd also like the buffer not to appear in the buffer list and be deleted when the window closes, but my current code (below) achieves this.
The window works exactly how I want if I
buftype to be
quickfix, but as the documentation states, "you are not supposed to set this manually"/"You are not supposed to change this!". Also, these buftypes will be reflected in some people's status lines, which is not ideal — the buffer is not actually either of these things.
My current settings for the buffer:
setlocal buftype=nofile setlocal bufhidden=delete setlocal nobuflisted setlocal noswapfile setlocal nomodifiable setlocal readonly setlocal nomodified
I had a look to see if I could hack it by setting up an autocmd to quit Vim if all the other windows are closed, but there doesn't appear to be a event for window closes.