From 5716eaa23974997fae9ac9a5d44293319d07b6a4 Mon Sep 17 00:00:00 2001 From: yan Date: Wed, 25 Jan 2012 12:09:40 -0800 Subject: [PATCH] Improve window killer (Q) - close window if multiple windows to same buffer exist --- vim/plugin/settings/window-killer.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vim/plugin/settings/window-killer.vim b/vim/plugin/settings/window-killer.vim index 71ff415..804b4b4 100644 --- a/vim/plugin/settings/window-killer.vim +++ b/vim/plugin/settings/window-killer.vim @@ -2,7 +2,9 @@ " (if there are multiple windows into the same buffer) " or kill the buffer entirely if it's the last window looking into that buffer function! CloseWindowOrKillBuffer() - if(bufwinnr('%')) > 1 + let number_of_windows_to_this_buffer = len(filter(range(1, winnr('$')), "winbufnr(v:val) == bufnr('%')")) + + if number_of_windows_to_this_buffer > 1 wincmd c else bdelete