vim - 如何根据NerdTree的根目录改变CtrlP的搜索目录?

标签 vim ctrlp

我希望我的 CtrlP 搜索目录在我更改 NerdTree 的根目录时动态更改。

插件到插件的通信如何在 vim 中工作?

最佳答案

它根本不起作用。 Vim 根本没有公开可以帮助插件作者使他们的插件无缝协同工作的通用接口(interface)。也许有一天…

与此同时,我们还剩下逆向工程、阅读源代码以及一如既往的 RTFM。

NERDTree 的 NERDTreeChDirMode指定插件在更改 Vim 的“当前目录”方面的行为的选项:

If the option is set to 2 then it behaves the same as if set to 1 except that
the CWD is changed whenever the tree root is changed. For example, if the CWD
is /home/marty/foobar and you make the node for /home/marty/foobar/baz the new
root then the CWD will become /home/marty/foobar/baz.

在 CtrlP 方面,ctrlp_working_path_mode选项听起来很有趣:
w - begin finding a root from the current working directory outside of CtrlP
    instead of from the directory of the current file (default). Only applies
    when "r" is also present.

所以看起来下面的两个选项会给你你想要的:
let g:NERDTreeChDirMode       = 2
let g:ctrlp_working_path_mode = 'rw'

关于vim - 如何根据NerdTree的根目录改变CtrlP的搜索目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21888869/

相关文章:

regex - 如何在vim中替换括号

shell - 下一行更少

git - 如何退出 Git 中的文本窗口?

vim - ctrlp 仍然搜索被忽略的目录

vim - 在CtrlP中,如何将 `mru`模式设置为默认模式?

vim - :vsplit autocomplete not working with/django/directory in VIM

ViM + CtrlP : Persist the cache between ViM sessions

vim - 如何在 INTELLIJ 中不使用箭头键进行选择

vim - Ctrl-p 找不到我的文件?

打开多个文件时 Vim 拆分窗口