Skip to content
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

readme update add script for automatically open NERDTree and focus on file #1192

Merged
merged 2 commits into from
Dec 18, 2020
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
14 changes: 14 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ 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 I open a NERDTree automatically when vim starts up if no files were specified?

Expand All @@ -103,6 +108,15 @@ autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif

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

---
#### 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 | else | NERDTree | wincmd p | endif
```

---
#### 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
Expand Down