When I open a new tab with different path from the previous file in VIM, NERDTree will still remains the same directory hierarchy of the previous file.

Is there a sync shortcut to change the current root directory to the new opened file's directory?

link|improve this question

73% accept rate
feedback

2 Answers

up vote 0 down vote accepted

I'm not sure if there's a NERDTree-specific way to do that, but you can always configure Vim so that it sets the working directory to the current file's directory:

autocmd BufEnter * lcd %:p:h

Now all what you have to do after opening a file in a new tab is :NERDTreeToggle in the new tab itself.

link|improve this answer
feedback

I use the following mapping to view the current buffer in NERDTree:

 map <leader>r :NERDTreeFind<cr>
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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