I have the following lines in my vimrc:

autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p

As a result the nerdtree plugin always opens when I load vim. How can I change the behaviour to load nerdtree iff vim is invoked from a particular directory.

For example, when open $ vim file.py from inside ~/workspace/something/ the loaded vim must load with nerdtree as I want any instance of vim involked from inside ~/workspace to have nerdtree loaded by default.

1 Answer 1


Editing the line to check for directory fixed my problem.

autocmd VimEnter */workspace/* NERDTree| wincmd p

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.