如何关闭在vim中的窗口中未显示的所有缓冲区?

前端之家收集整理的这篇文章主要介绍了如何关闭在vim中的窗口中未显示的所有缓冲区?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在vim中打开了大量缓冲区,只有少数缓冲区在拆分窗口或其他选项卡中打开。有没有办法关闭除了那些分裂或制表符中当前可见的那些?
这里有一个替代解决方案,你可以放在.vimrc中:
function! Wipeout()
  " list of *all* buffer numbers
  let l:buffers = range(1,bufnr('$'))

  " what tab page are we in?
  let l:currentTab = tabpagenr()
  try
    " go through all tab pages
    let l:tab = 0
    while l:tab < tabpagenr('$')
      let l:tab += 1

      " go through all windows
      let l:win = 0
      while l:win < winnr('$')
        let l:win += 1
        " whatever buffer is in this window in this tab,remove it from
        " l:buffers list
        let l:thisbuf = winbufnr(l:win)
        call remove(l:buffers,index(l:buffers,l:thisbuf))
      endwhile
    endwhile

    " if there are any buffers left,delete them
    if len(l:buffers)
      execute 'bwipeout' join(l:buffers)
    endif
  finally
    " go back to our original tab page
    execute 'tabnext' l:currentTab
  endtry
endfunction

使用:调用Wipeout()。

原文链接:/bash/390350.html

猜你在找的Bash相关文章