diff --git a/.config/vim/vimrc b/.config/vim/vimrc index 38cee9a..c0f9445 100644 --- a/.config/vim/vimrc +++ b/.config/vim/vimrc @@ -102,6 +102,11 @@ augroup CloseVimTree autocmd! bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif augroup END +augroup PreventBuffer + autocmd FileType nerdtree let t:nerdtree_winnr = bufwinnr('%') + autocmd BufWinEnter * call PreventBuffersInNERDTree() +augroup END + "" Functions function! CloseTab() @@ -120,6 +125,18 @@ function! CloseTab() endif endfunction +function! PreventBuffersInNERDTree() + if bufname('#') =~ 'NERD_tree' && bufname('%') !~ 'NERD_tree' + \ && exists('t:nerdtree_winnr') && bufwinnr('%') == t:nerdtree_winnr + \ && &buftype == '' + let bufnum = bufnr('%') + close + execute 'b ' . bufnum + execute ':NERDTree' + execute "normal! \\" + endif +endfunction + "" Keybindings " Tab/Shift+Tab functionality