Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NERDTree reload new files

Tags:

vim

nerdtree

People also ask

How do you refresh NERDTree?

Keymap to Refresh NERDTree Once set, pressing Leader + r would refresh NERDTree .

How do I create a new file in NERDTree?

Press m to bring up the NERDTree Filesystem Menu. This menu allows you to create, rename, and delete files and directories. Type a to add a child node and then simply enter the filename. You're done!

How do I show hidden files in NERDTree?

Press I ( Shift + i ) to toggle hidden files in the NERDTree explorer window. For more detail, access the NERDTree help file :help NERD_tree. txt and search for "hidden". And to hide hidden files by default, put let NERDTreeShowHidden=0 into your vimrc.


You could close and reopen NERDTree or simply hit r to refresh the current directory's listing or R to refresh the root directory's listing .

Do you see "Press ? for help" at the top of the NERDTree window? It means that you can press ? for help. If you do, you will see an exhaustive listing of NERDTree shortcuts. That's neat.

More generally, many plugins have a thorough documentation that you can access with :help <pluginame>.


As @romainl answered above; press r to refresh current directory or R to refresh root directory.

You can consider adding new files from nerdTree itself by pressing m, then a to add a new file (or directory by adding a trailing slash). This way you don't need to refresh nerdTree to see the new added file.


Refresh NERDTree

Instead of hitting R in the NERDTree window, I use a custom map that does it for me:

nmap <Leader>r :NERDTreeRefreshRoot

I've mapped it to Leader + r, but you can map it to whatever you want.


Explanation:

  • It first switches to the NERDTree window
  • Then refreshes the Root Node (by simulating the R key)
  • And finally switches back to the previous window

Note: You can add a last step to refresh CtrlP along with NERDTree


You can hit R button by using feedkeys function. Just like this:

call feedkeys("R")  

I have defined a function in my .vimrc file:

fun! ToggleNERDTreeWithRefresh()
    :NERDTreeToggle 
    if(exists("b:NERDTreeType") == 1)
        call feedkeys("R")  
    endif   
endf 

nmap <silent> <c-l> :call ToggleNERDTreeWithRefresh()<cr>  

So, when I type ctrl+l, the NERDTree will be toggled and refresh root directory.