Automatically quit vim if NERDTree is last and only buffer

后端 未结 5 767
鱼传尺愫
鱼传尺愫 2020-12-07 22:36

I have the following in my .vimrc:

\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"\"         


        
5条回答
  •  天涯浪人
    2020-12-07 22:48

    function! s:CloseIfOnlyControlWinLeft()
      if winnr("$") != 1
        return
      endif
      if (exists("t:NERDTreeBufName") && bufwinnr(t:NERDTreeBufName) != -1)
            \ || &buftype == 'quickfix'
        q
      endif
    endfunction
    augroup CloseIfOnlyControlWinLeft
      au!
      au BufEnter * call s:CloseIfOnlyControlWinLeft()
    augroup END
    

    From my vimrc, based on a version from janus repo.

    Enhancements: also close if only a quickfix window is left. It uses the BufEnter autocommand instead, which is required for &bt to work properly.

提交回复
热议问题