Skip to content

Commit 148e857

Browse files
Merge pull request #628 from ggicci/master
Add note in README: trick to open NERDTree as a window on startup.
2 parents f26eaf8 + a229d8b commit 148e857

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

README.markdown

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,15 @@ Stick this in your vimrc:
100100

101101
Note: Now start vim with plain `vim`, not `vim .`
102102

103+
103104
---
104-
> How can I open NERDTree on startup, and have my cursor start in the other window?
105+
> How can I open NERDTree as a window automatically when vim starts up on opening a directory?
105106
106-
Stick this in your vimrc:
107+
autocmd StdinReadPre * let s:std_in=1
108+
autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | endif
107109

108-
autocmd vimenter * NERDTree
109-
autocmd vimenter * wincmd p
110+
This trick also prevents NERDTree from hiding when first select a file.
110111

111-
*via [stackoverflow/Yohann](http://stackoverflow.com/questions/4277808/nerdtree-auto-focus-to-file-when-opened-in-new-tab/19330023#19330023)*
112-
113112
---
114113
> How can I map a specific key or shortcut to open NERDTree?
115114

0 commit comments

Comments
 (0)