Is there a way to refresh the root node tree without the NERDTree window/buffer opened? i.e. some kind of command that we can map to a key?
Would love to have this too!!
Currently using vimfiler and it works great. It also supports this feature.
I'm not really looking to move away from NERDTree. It does everything I need and I make heavy use of both bookmarks and NERDTreeFind.
My only issue is that NERDTreeFind does not take an argument, like NERDTreeToggle. So, I can't open a tree with a root in a given directory and highlight current file within that tree's hierarchy.
To get around this issue, I'm using:
exec 'NERDTreeToggle ' . b:nerdtree_root
exec 'NERDTreeClose'
exec 'NERDTreeFind'
But, it is obviously a less then idea solution. I was hoping @scrooloose would be able to advice on a better approach…
PS: Just in case anyone is interested, here is the full code for what I'm doing: gist:06511ed246ff63e2e428
I custom a map to do this:
nmap <leader>rn :NERDTree<cr> \| R \| <c-w><c-p>
Just get to the NERDTree and do the refresh then jump back to previous window
@lingceng thank you
Gentlemen, in the latest version (pushed just now) you can do:
:call g:NERDTree.ForCurrentTab().getRoot().refresh()
Let me know if there are issues - its 0200 here, so issues are possible :)
@scrooloose Thanks for this. Just FYI, it seems a lot slower than my current workaround, which is this;
" Refresh NERDTree pane
nmap <leader>nr :NERDTreeFocus<cr> \| R \| <c-w><c-p>
If I replace the "R" part with the new :call function, it seems to take a lot longer for the NERDTree pane to update - a few seconds, versus less than a second with 'R'. I tested this by touching and removing a file from outside of vim, then forcing the pane to refresh.
For anyone seeing this on 2016, this worked for me:
autocmd CursorHold,CursorHoldI * call NERDTreeFocus() | call g:NERDTree.ForCurrentTab().getRoot().refresh() | call g:NERDTree.ForCurrentTab().render() | wincmd w
Enjoy!
nmap <Leader>r :NERDTreeFocus<cr>R<c-w><c-p>
Most helpful comment
For anyone seeing this on 2016, this worked for me:
Enjoy!