NERDTree Load Particular Directory Automatically
Asked Answered
Y

3

11

I'm using gvim in windows.By default nerdtree loads C:\ drive as default.I like to change it to E:\ drive.How to achieve this?

Whenever I try to start NERDTree using :NERDTree command, I get this error E492: Not an editor command: NERDTree

Ylla answered 27/4, 2011 at 7:34 Comment(0)
R
23

I have the following code in my vimrc file

cd ~/documents
map <F2> :NERDTreeToggle<CR>
" open Nerd Tree in folder of file in active buffer
map <Leader>nt :NERDTree %:p:h<CR>

The cd command is not NerdTree specific. It just changes the working directory when Vim starts to something which for me is sensible.

Rubbing answered 27/4, 2011 at 8:50 Comment(1)
How does %:p:h open the folder of file in active buffer?Mme
R
6

From the NERDTree help-file: :NERDTree [<start-directory> | <bookmark>] *:NERDTree* Opens a fresh NERD tree. The root of the tree depends on the argument given. There are 3 cases: If no argument is given, the current directory will be used. If a directory is given, that will be used. If a bookmark name is given, the corresponding directory will be used. For example: > :NERDTree /home/marty/vim7/src :NERDTree foo (foo is the name of a bookmark)

Rawhide answered 26/9, 2014 at 14:51 Comment(0)
U
1

In my vimrc file,I use this autocmd vimenter * NERDTree G:\.The G:\ should be set your default drive,but, it's only the NERDTree's work dir. add cd G:\change the vim start work dir.Just like Jeromy Anglim said that.

Undo answered 22/7, 2019 at 11:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.