我正在使用:bd!
关闭当前缓冲区。有时,我在两个分割缓冲区中打开长文件以查看文件的不同部分。
但是如果我在缓冲区中使用:bd!
,则两个分割缓冲区都在关闭。
如何只关闭缓冲区的一个实例?
更新
我写了一个函数来做它,但它不起作用:
function! g:CloseSplitOrBuffer()
" Is the file opened at least two times?
if bufwinnr(expand('%:p')) > 1
execute ':q'
else
execute ':bd!'
endif
endfunction
if condition
总是true
,即使我关闭所有其他分组。
答案 0 :(得分:1)
You can close the current window: Ctl-w c
You can also close all the windows but the current one: Ctl-w o
答案 1 :(得分:1)
这是解决方案:
function! g:CloseSplitOrBuffer()
" Is the file opened at least two times?
if winnr('$') > 1
execute ':q'
else
execute ':bd!'
endif
endfunction
感谢@LievenKeersmaekers