Created
September 18, 2011 19:34
-
-
Save maxim/1225452 to your computer and use it in GitHub Desktop.
Delete buffer if last window, otherwise close window
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| " Closes window if there are more windows opened to the same buffer. | |
| " Otherwise deletes buffer. | |
| fun! WinQuitOrBufDelete () | |
| let win_cnt = 0 | |
| for wnr in range(1, winnr("$")) | |
| if winbufnr(wnr) == bufnr("%") | |
| let win_cnt += 1 | |
| endif | |
| if win_cnt == 2 | |
| close | |
| return | |
| endif | |
| endfor | |
| bd | |
| endf |
SethMilliken
commented
Sep 18, 2011
function! CloseBuffer()
if len(filter(range(1,winnr('$')), 'v:val != bufnr("%")')) > 1
echom 'hiding the window'
else
echom 'deleting this buffer'
endif
endfunction
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment