autochdir
自动将当前工作目录设置为光标所在的当前文件。如果光标位于 NERDTree 窗口中,我想将 autochdir
排除在更改目录之外。
例如,如果我正在处理的当前文件在 ~/foo
中,NERDTree 窗口在 ~/lots/of/stuff/here
中,我想转到 NERDTree 窗口并将当前工作目录设置为 ~/foo
。
那样的话,可以应用CD
键绑定(bind),这会将NERDTree 的根树节点设置为~/foo
。否则,通过导航到 ~/foo
,然后应用 cd
键绑定(bind),在 NERDTree 窗口中手动更改根树节点是非常不方便的。
最佳答案
来自 :help autochdir
:
This option is provided for backward compatibility with the Vim released with Sun ONE Studio 4 Enterprise Edition.
Note: When this option is on some plugins may not work.
即它已经过时、不灵活并且会破坏插件。我建议您不要使用它,而是使用一种替代的、更可配置的机制 here .例如,
autocmd BufEnter * if &ft !~ '^nerdtree$' | silent! lcd %:p:h | endif
但是,虽然这不会在您拉出 NERDTree 时更改当前目录,但它也不会保留它。我不是 100% 确定你在最后一段中的意思。
关于vim - autochdir 和 NERDTree,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27183726/