Skip to content

Commit

Permalink
_vimrc.plugins: close Vim or a tab automatically when NERDTree is the…
Browse files Browse the repository at this point in the history
… last window
  • Loading branch information
yousong committed Jan 3, 2025
1 parent b357209 commit 902153b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions data/_vimrc.plugins
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,17 @@ let g:ctrlp_custom_ignore = {
""""""" scrooloose/nerdtree
" q to quit
nmap <C-N> :NERDTree %:p:h<CR>
" How can I close vim if the only window left open is a NERDTree?
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
let NERDTreeIgnore = ['\.pyc$']
let NERDTreeMapOpenSplit = 's'
let NERDTreeMapOpenVSplit = 'v'
" https://github.com/preservim/nerdtree?tab=readme-ov-file#how-can-i-close-vim-or-a-tab-automatically-when-nerdtree-is-the-last-window
if v:version >= 900
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | call feedkeys(":quit\<CR>:\<BS>") | endif
else
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
endif


""""""" scrooloose/nerdcommenter
Expand Down

0 comments on commit 902153b

Please sign in to comment.