I believe your best bet is to utilize the command
:NERDTreeCWD *:NERDTreeCWD* Change the NERDTree root to the current working directory. If no NERDTree exists for this tab, a new one is opened.
Now you can't override
:cd but you could create a custom command that's close...it just has to start with a capital letter:
:com! -nargs=1 -bar -complete=dir Cd :cd <args> | NERDTreeCWD
Use just like
Never mind all that...this just occurred to me and is much better IMO.
There is an auto command event triggered by directory changeauto command event triggered by directory change
augroup DIRCHANGE au! autocmd DirChanged global :NERDTreeCWD augroup END
Note that this is only for the global directory change of
:cd. To have this work with
:lcd you'd change
window or add another
autocmd line if you wantedcould include both by separating them with commas. Full list:
"window" to trigger on `:lcd` "tabpage" to trigger on `:tcd` "global" to trigger on `:cd` "auto" to trigger on 'autochdir'. "drop" to trigger on editing a file