在 NERDtree 上导航时如何更改 vim 工作目录

How to change vim working directory when navigating on NERDtree

在 NERDtree 中,如果您按 C,它会更改光标下文件夹的 NERDtree 的根目录。我想使用此命令更改 vim 的工作目录(就像您使用 :lcd \path\to\directory 时一样)。有谁知道这样做的方法吗??

您可以将选项 NERDTreeChDirMode 设置为值 2 这将在更改树根时更改 vim 的 CWD。

'NERDTreeChDirMode'

Values: 0, 1 or 2. Default: 0.

Use this option to tell the script when (if at all) to change the current working directory (CWD) for vim.

If it is set to 0 then the CWD is never changed by the NERD tree.

If set to 1 then the CWD is changed when the NERD tree is first loaded to the directory it is initialized in. For example, if you start the NERD tree with :NERDTree /home/marty/foobar

then the CWD will be changed to /home/marty/foobar and will not be changed again unless you init another NERD tree with a similar command.

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.