简体   繁体   English

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

[英]How to change vim working directory when navigating on NERDtree

in NERDtree if you press C it changes the root of the NERDtree for the folder under the cursor.在 NERDtree 中,如果您按C它会更改光标下文件夹的 NERDtree 的根目录。 i'd like to change vim's working directory (like when you use: :lcd \\path\\to\\directory ) by using this command.我想使用此命令更改 vim 的工作目录(例如当您使用: :lcd \\path\\to\\directory )。 anyone knows a way of doing it??有人知道这样做的方法吗??

You can set the option NERDTreeChDirMode to value 2 this will change vim's CWD when the tree root is changed.您可以将选项NERDTreeChDirMode设置为值2这将在更改树根时更改 vim 的 CWD。

'NERDTreeChDirMode' 'NERDTreeChDirMode'

Values: 0, 1 or 2. Default: 0.值:0、1 或 2。默认值:0。

Use this option to tell the script when (if at all) to change the current working directory (CWD) for vim.使用此选项告诉脚本何时(如果有的话)更改 vim 的当前工作目录 (CWD)。

If it is set to 0 then the CWD is never changed by the NERD tree.如果它被设置为 0,那么 CWD 永远不会被 NERD 树改变。

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如果设置为 1,那么当 NERD 树首次加载到它初始化的目录时,CWD 会更改。例如,如果您使用:NERDTree /home/marty/foobar启动 NERD 树

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.然后 CWD 将更改为 /home/marty/foobar 并且不会再次更改,除非您使用类似的命令初始化另一个 NERD 树。

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.如果该选项设置为 2,则它的行为与设置为 1 的行为相同,不同之处在于每当树根更改时 CWD 也会更改。 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.例如,如果 CWD 是 /home/marty/foobar 并且您将 /home/marty/foobar/baz 的节点设为新根,那么 CWD 将成为 /home/marty/foobar/baz。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM