如何在NERDTree插件中刷新
当我在 vim 中使用(目录 A 中)NERDTree
打开文件时,它运行良好。
但是,如果我在另一个目录(目录 B)中再打开一个文件,它不会刷新以显示目录 B 的内容(尽管它仍然显示目录 A)。
NERDTree
可以自动刷新吗?
When I open a file in vim with (Directory A in) NERDTree
, it works well.
But if I open one more file in another directory (Directory B), it doesn't refresh to show the contents of directory B (While it still shows directory A).
Can NERDTree
automatically refresh by itself?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
来自 https://gist.github.com/geekontheway/2667442 :只需点击
r
或R
键刷新当前树。可以映射到.vimrc
中的自动刷新From https://gist.github.com/geekontheway/2667442 : just hit the
r
orR
key to refresh the current tree. Could be mapped to auto refresh in.vimrc
刷新 NERDTree 的键盘映射
我没有切换到 NERDTree 窗口,点击 R 然后切换回来,而是使用自定义映射来完成此操作:
设置后,按 Leader + r 将刷新 NERDTree。
注意:由于我也使用 CtrlP,因此我的实际按键映射有最后一步在之后刷新 CtrlP刷新 NERDTree
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: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
我讨厌必须手动刷新我的 NERDTree 插件的想法。因此,我已将其添加到我的
.vimrc
中:现在,每次打开 NERDTree 时都会刷新它。
I detested the idea of having to manually refresh my NERDTree plugin. So, I've added this to my
.vimrc
:Now, NERDTree refreshes every time I open it.
打开新文件后,只需发出
:NERDTreeFind
命令。它将选择 NerdTree 中当前编辑的文件节点。如果该节点不存在,则 NerdTree 将初始化一棵新树,并将根作为当前文件的目录。您可以在打开 vim 时使用自动命令来跟踪目录。
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.
对于 2016 年看到这个的人来说,这对我有用:
享受吧!
For anyone seeing this on 2016, this worked for me:
Enjoy!
无论打开什么新文件,NerdTree 都会始终指向最初打开 vim 的目录。
要更改它,请将光标放在 NerdTree 窗口内所需的目录节点上,然后按
cd
。NerdTree 将在命令行中确认目录更改:
请注意,这通常也会更改 vim 的工作目录,这在运行
:edit somefile
等命令时很重要。NerdTree will keep pointing at the directory from which vim was originally opened no matter what new files are opened.
In order to change it, place the cursor on the desired directory node inside the NerdTree window and press
cd
.NerdTree will confirm the directory change in the command line:
Note that this also changes the working directory of vim in general which is important when running commands like
:edit somefile
.