What I'm trying to do is, when a window is closed(bw,bunload)/opened (NOT fzf, quickfix q:, buftype=nofile, etc..) resize all the other windows.

This code works but I was wondering if there was a better way or a command that I don't know of? Another option would be to build a list or dictionary and keep track of open/closed windows of visible buffers with real files (overkill?).

fu! s:WindowsHelper(...)
    if a:0 == 1
        if a:1 =~ '\v.*Command' ||  a:1 =~ '\v^\s*$' || a:1 =~ 'bufferEmpty'
            return 0
    call s:ResizeWindows()

augroup WindowsStuff
    au BufEnter *   if bufname(winbufnr(winnr()))   == '' | call s:WindowsHelper('bufferEmpty')
    au WinNew * call s:WindowsHelper()
    au BufUnload * call s:WindowsHelper(bufname(winbufnr(winnr())))
augroup end

P.S Ive crashed a few times but can't fully blame the augroup WindowsStuff yet, I'm waiting for my next crash to look at the verbose file.

  • Hello, I am not sure to fully understand your question. Normally when you close a window, all the remaining windows will take the place left. Perhaps ":help equalalways" can help. Jan 3, 2021 at 23:28
  • I'm doing a custom resizing of all windows when a window is closed or opened. Maybe I should look into getbufinfo() and if it's not visible trigger the custom windows sizes.
    – ritchie
    Jan 3, 2021 at 23:54


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.