How to refresh in NERDTree plugin

From https://gist.github.com/geekontheway/2667442 : just hit the r or R key to refresh the current tree. Could be mapped to auto refresh in .vimrc


Keymap to Refresh NERDTree

Instead of switching to the NERDTree window, hitting R and switching back, I use a custom map that does it for me:

nmap <Leader>r :NERDTreeFocus<cr>R<c-w><c-p>

Once set, pressing Leader + r would refresh NERDTree.


Note: Since I also use CtrlP, my actual key map has a last step to refresh CtrlP after refreshing NERDTree


After you have opened the new file just issue the :NERDTreeFind command. It will select the current editing file node in the NerdTree. If the node does not exists then the NerdTree will initialize a new tree with the root as the current file's directory.

You can use the autocommand to track the directory while opening vim.

au VimEnter * NERDTreeFind