【问题标题】:vim: open NERDTree and move the cursor to the file editing areavim:打开NERDTree,将光标移动到文件编辑区
【发布时间】:2014-07-17 16:30:43
【问题描述】:

我尝试按照 NERDTree github 站点的常见问题解答部分中的说明进行操作:

"Q. 如何在 vim 启动时自动打开 NERDTree?"

"A. 把这个粘贴到你的 vimrc 中:autocmd vimenter * NERDTree"

它可以工作,但是当我打开一个文件时,光标停留在 NEARDTree 资源管理器区域而不是在编辑区域,我必须按 Ctrl+w+l 将其移回,我应该在我的 .vimrc 文件中写入什么来自动化在编辑区设置光标?

【问题讨论】:

标签: vim nerdtree


【解决方案1】:

只需在后面添加第二条命令:

autocmd VimEnter * NERDTree
autocmd VimEnter * wincmd p

或者如果你想要一个单线

autocmd VimEnter * NERDTree | wincmd p

【讨论】:

  • 谢谢,它有效!顺便说一句,您的单行代码最后是否省略了p?没有它我会得到一个错误。
【解决方案2】:

如果您想在未指定文件的情况下保持默认行为(即,如果有要编辑的文件,则离开 NERDTree 资源管理器),您可以使用此设置:

autocmd VimEnter * if argc() == 1 | NERDTree | wincmd p | endif

【讨论】:

  • 您忘记了默认操作。整行应该是autocmd VimEnter * if argc() == 1 | NERDTree | wincmd p | else | NERDTree | endif
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-21
相关资源
最近更新 更多