diff --git a/scripts/vimrc-config b/scripts/vimrc-config index 5ba67d8..ec35f5d 100644 --- a/scripts/vimrc-config +++ b/scripts/vimrc-config @@ -35,3 +35,14 @@ set colorcolumn=80 syntax enable set background=dark colorscheme delek + +" Start NERDTree when vim starts +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * NERDTree | if argc() > 0 || exists('s:std_in') | wincmd p | endif + +" Close the tab if NERDTree is the only window remaining in it. +autocmd BufEnter * if winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif + +" If another buffer tries to replace NERDTree, put it in the other window, and bring back NERDTree. +autocmd BufEnter * if bufname('#') =~ 'NERD_tree_\d\+' && bufname('%') !~ 'NERD_tree_\d\+' && winnr('$') > 1 | + \ let buf=bufnr() | buffer# | execute "normal! \w" | execute 'buffer'.buf | endif