From 4cb97629991fcfe83e35ec4e0e347b71617009ab Mon Sep 17 00:00:00 2001 From: Ggicci Date: Sun, 9 Oct 2016 15:11:27 +0800 Subject: [PATCH 1/4] Update readme, trick to avoid hiding nerdtree after first file open. --- README.markdown | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.markdown b/README.markdown index de28e05..372b28a 100644 --- a/README.markdown +++ b/README.markdown @@ -100,6 +100,11 @@ Stick this in your vimrc: Note: Now start vim with plain `vim`, not `vim .` +Or use the following directives if you prefer using `vim .`: + + autocmd StdinReadPre * let s:std_in=1 + autocmd VimEnter * if argc() == 1 && argv()[0] == '.' && !exists("s:std_in") | NERDTree | wincmd p | ene | endif + --- > How can I open NERDTree on startup, and have my cursor start in the other window? From 1c0d9efe6c10c42815782e6a3609a73a335ec46b Mon Sep 17 00:00:00 2001 From: Ggicci Date: Sun, 9 Oct 2016 15:26:48 +0800 Subject: [PATCH 2/4] Update readme, trick to open NERDTree as a tab window. --- README.markdown | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index 372b28a..a72894a 100644 --- a/README.markdown +++ b/README.markdown @@ -100,10 +100,14 @@ Stick this in your vimrc: Note: Now start vim with plain `vim`, not `vim .` -Or use the following directives if you prefer using `vim .`: + +--- +> How can I open NERDTree as a tab window automatically when vim opens a directory? autocmd StdinReadPre * let s:std_in=1 - autocmd VimEnter * if argc() == 1 && argv()[0] == '.' && !exists("s:std_in") | NERDTree | wincmd p | ene | endif + autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | NERDTree | wincmd p | ene | endif + +This trick also prevents NERDTree from hiding when first select a file. --- > How can I open NERDTree on startup, and have my cursor start in the other window? From b78fa833730de846c132a7318a00d8fb4fe29581 Mon Sep 17 00:00:00 2001 From: Ggicci Date: Sun, 9 Oct 2016 20:28:33 +0800 Subject: [PATCH 3/4] Fix opening current directory in NERDTree tab. --- README.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.markdown b/README.markdown index a72894a..34b9ef1 100644 --- a/README.markdown +++ b/README.markdown @@ -102,10 +102,10 @@ Note: Now start vim with plain `vim`, not `vim .` --- -> How can I open NERDTree as a tab window automatically when vim opens a directory? +> How can I open NERDTree as a tab window automatically when vim starts up on opening a directory? autocmd StdinReadPre * let s:std_in=1 - autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | NERDTree | wincmd p | ene | endif + autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif This trick also prevents NERDTree from hiding when first select a file. From a229d8bb610e522b2777ddad9374c4f8afa85fbf Mon Sep 17 00:00:00 2001 From: Ggicci Date: Tue, 11 Oct 2016 00:02:29 +0800 Subject: [PATCH 4/4] Remove a similar tip in README file. --- README.markdown | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/README.markdown b/README.markdown index 34b9ef1..9fcba09 100644 --- a/README.markdown +++ b/README.markdown @@ -102,23 +102,13 @@ Note: Now start vim with plain `vim`, not `vim .` --- -> How can I open NERDTree as a tab window automatically when vim starts up on opening a directory? +> How can I open NERDTree as a window automatically when vim starts up on opening a directory? autocmd StdinReadPre * let s:std_in=1 autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif This trick also prevents NERDTree from hiding when first select a file. ---- -> How can I open NERDTree on startup, and have my cursor start in the other window? - -Stick this in your vimrc: - - autocmd vimenter * NERDTree - autocmd vimenter * wincmd p - - *via [stackoverflow/Yohann](http://stackoverflow.com/questions/4277808/nerdtree-auto-focus-to-file-when-opened-in-new-tab/19330023#19330023)* - --- > How can I map a specific key or shortcut to open NERDTree?