Skip to content

Add note in README: trick to open NERDTree as a window on startup. #628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 10, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,15 @@ Stick this in your vimrc:

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


---
> How can I open NERDTree on startup, and have my cursor start in the other window?
> How can I open NERDTree as a window automatically when vim starts up on opening a directory?

Stick this in your vimrc:
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

autocmd vimenter * NERDTree
autocmd vimenter * wincmd p
This trick also prevents NERDTree from hiding when first select a file.

*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?

Expand Down