有时tag跳转打开了很多缓冲区,一个个关闭又太麻烦,在vim定义关闭所有其它缓冲区的函数 实现如下: command! BcloseOthers call <SID>BufCloseOthers() function! <SID>BufCloseOthers() let l:currentBufNum = bufnr("%") let l:alternateBufNum = bufnr("#") for i in range(1,bufnr("$")) if buflisted(i) if i!=l:currentBufNum execute("bdelete ".i) endif endif endfor endfunction map <leader>bdo :BcloseOthers<cr>