NERDTree 重新加载新文件

发布于 2024-12-25 22:08:57 字数 104 浏览 0 评论 0原文

如果我将一个文件添加到在 NERDTree 中打开的同一目录中,我可以看到添加的文件的唯一方法是退出 vim 并再次启动它。

有没有办法可以重新加载 NERDTree 中的文件?

If I add a file to the same directory opened in NERDTree, the only way I can see the file added is if I quit vim and start it again .

Is there a way I can reload the files in NERDTree?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

你怎么这么可爱啊 2025-01-01 22:08:57

您可以关闭并重新打开 NERDTree,或者只需点击 r 刷新当前目录的列表,或点击 R 刷新根目录的列表。

您是否在 NERDTree 窗口顶部看到“按 ? 寻求帮助”?这意味着您可以按 ? 寻求帮助。如果这样做,您将看到 NERDTree 快捷方式的详尽列表。这很整洁。

更一般地说,许多插件都有完整的文档,您可以使用 :help 访问这些文档。

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>.

忘你却要生生世世 2025-01-01 22:08:57

正如@romainl 上面回答的那样;按r刷新当前目录或按R刷新根目录。

您可以考虑从 nerdTree 本身添加新文件,方法是按 m,然后按 a 添加新文件(或通过添加尾部斜杠来添加目录)。这样你就不需要刷新 nerdTree 来查看新添加的文件。

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.

久伴你 2025-01-01 22:08:57

刷新 NERDTree

我没有在 NERDTree 窗口中点击 R,而是使用自定义地图来完成此操作:

nmap <Leader>r :NERDTreeRefreshRoot

我已将其映射到 Leader + r,但您可以将其映射到您想要的任何内容。


解释:

  • 首先切换到NERDTree窗口
  • ,然后刷新根节点(通过模拟R键)
  • ,最后切换回上一个窗口

注意:您可以添加最后一步刷新 CtrlP 以及NERDTree

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

寒尘 2025-01-01 22:08:57

您可以使用 feedkeys 功能点击 R 按钮。就像这样:

call feedkeys("R")  

我在 .vimrc 文件中定义了一个函数:

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

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

因此,当我输入 ctrl+l 时,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.

黎歌 2025-01-01 22:08:57

就我个人而言,我更喜欢在聚焦 NERDTree 窗口时自动触发刷新。这个自动命令(在您的 .vimrc 中)将执行此操作

autocmd BufEnter NERD_tree_* |执行“普通R”

Personally I prefer to trigger the refresh automatically when focusing the NERDTree window. This autocommand (in your .vimrc) will do it

autocmd BufEnter NERD_tree_* | execute 'normal R'

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文