使用vim时,如果打开很多窗口, 占用好几行屏幕, 一个一个关闭又太麻烦, 下面命令写入vimrc文件, 在normal模式下,按<leader>bdo可以关闭所有非当前buffer
我的<leader>配置为分号‘;’, 如下:
let mapleader=";"
let maplocalleader=";"
command! BcloseOthers call BufCloseOthers()
function! BufCloseOthers()
let l:currentBufNum = bufnr("%")
let l:alternateBufNum = bufnr("#")
fori in range(1,bufnr("$"))
ifbuflisted(i)
ifi!=l:currentBufNum
execute("bdelete ".i)
endif
endif
endfor
endfunction
nmap bdo :BcloseOthers
网友评论