Vim NERDTree – Synchronize NERDTree with Current Tab File Path

gvimnerdtreevimvim-plugins

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?

Best Answer

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.

Related Question