From 3a2d10e1f5d024b74d8f3087b6c5c3344357acb6 Mon Sep 17 00:00:00 2001 From: buncis Date: Thu, 17 Dec 2020 11:42:24 +0700 Subject: [PATCH 1/2] update readme for auto startup NERDTree and focus on file --- README.markdown | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.markdown b/README.markdown index 018923cf..ae7868c3 100644 --- a/README.markdown +++ b/README.markdown @@ -92,6 +92,20 @@ If you are interested in this behaviour then consider [vim-nerdtree-tabs](https: Stick this in your vimrc: `autocmd vimenter * NERDTree` +--- +#### How can I open a NERDTree automatically when vim starts up and autofocus on file? + +Stick this in your vimrc: `autocmd vimenter * NERDTree | wincmd p` + +--- +#### How can to autofocus on file and focus on NERDTREE when no files were specified? + +Stick this in your vimrc: +```vim +autocmd StdinReadPre * let s:std_in=1 +autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | else | NERDTree | wincmd p | endif +``` + --- #### How can I open a NERDTree automatically when vim starts up if no files were specified? From fefaebbddaa98c6642d52b85a6c734b061758be2 Mon Sep 17 00:00:00 2001 From: buncis Date: Thu, 17 Dec 2020 11:44:32 +0700 Subject: [PATCH 2/2] readme update add how to open NERDTree automatically and focus on file --- README.markdown | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.markdown b/README.markdown index ae7868c3..da87fbca 100644 --- a/README.markdown +++ b/README.markdown @@ -98,25 +98,25 @@ Stick this in your vimrc: `autocmd vimenter * NERDTree` Stick this in your vimrc: `autocmd vimenter * NERDTree | wincmd p` --- -#### How can to autofocus on file and focus on NERDTREE when no files were specified? +#### How can I open a NERDTree automatically when vim starts up if no files were specified? Stick this in your vimrc: ```vim autocmd StdinReadPre * let s:std_in=1 -autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | else | NERDTree | wincmd p | endif +autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif ``` +Note: Now start vim with plain `vim`, not `vim .` + --- -#### How can I open a NERDTree automatically when vim starts up if no files were specified? +#### How to autofocus on file and focus on NERDTREE when no files were specified? Stick this in your vimrc: ```vim autocmd StdinReadPre * let s:std_in=1 -autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif +autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | else | NERDTree | wincmd p | endif ``` -Note: Now start vim with plain `vim`, not `vim .` - --- #### What if I'm also opening a saved session, for example `vim -S session_file.vim`? I don't want NERDTree to open in that scenario. ```vim