Created
April 30, 2014 23:54
-
-
Save juanxo/1b3682b76b08d1bfed7e to your computer and use it in GitHub Desktop.
Vim function to improve handling of closing buffers
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
| map <leader>bd :Bclose<cr> | |
| command! Bclose call <SID>BufcloseCloseIt() | |
| function! <SID>BufcloseCloseIt() | |
| let l:currentBufNum = bufnr("%") | |
| let l:alternateBufNum = bufnr("#") | |
| if buflisted(l:alternateBufNum) | |
| buffer # | |
| else | |
| bnext | |
| endif | |
| if bufnr("%") == l:currentBufNum | |
| new | |
| endif | |
| if buflisted(l:currentBufNum) | |
| execute("bdelete! ".l:currentBufNum) | |
| endif | |
| endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment