Skip to content

Instantly share code, notes, and snippets.

@apirak
Last active March 15, 2022 01:10
Show Gist options
  • Save apirak/23565636764e4b00297a10702f744b69 to your computer and use it in GitHub Desktop.
Save apirak/23565636764e4b00297a10702f744b69 to your computer and use it in GitHub Desktop.
" Start NERDTree when Vim is started without file arguments.
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists('s:std_in') | NERDTree | endif
" Exit Vim if NERDTree is the only window remaining in the only tab.
autocmd BufEnter * if tabpagenr('$') == 1 && winnr('$') == 1 && exists('b:NERDTree') && b:NERDTree.isTabTree() | quit | endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment