以非相邻分割打开 Nerdtree 文件
通常,我通过按 Ctrl+H 两次将光标移动到屏幕的左边缘来切换到 Nerdtree 文件缓冲区。然而,这意味着当我打开文件时,它们总是位于 NERDTree 窗口附近的分割中。如何打开与 NERDTree 窗口不相邻的分割中的文件?
Normally I switch over to the Nerdtree file buffer by hitting Ctrl+H twice to move the cursor over to the left edge of the screen. However, this means that when I open files, they are always in the split adjacent to the NERDTree window. How can I open files in the split that's not adjacent to the NERDTree window?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果按 o 或 Enter 键,NERDtree 将在上一个窗口中打开文件。您可以按 i 在前一个窗口的拆分中打开它,或按 s 在垂直拆分中打开它。
听起来您已将 Ctrl-H 映射到 Ctrl-W h。不让 NERDtree 在与 NERDTree 窗口相邻的窗口中打开文件的技巧是不让相邻窗口是前一个窗口。
要实现此目的,请关闭 NERDTree 窗口。 (:NERDTreeToggle,或者任何你用来切换 NERDTree 的映射键)。然后移至要在其中打开文件的相应窗口。然后再次打开 NERDTree。现在,您可以使用 o 或 Enter... 在上一个窗口中打开文件,或者使用 i 或 s 分割打开文件。
为了避免切换 NERDTree 窗口的打开/关闭,您可能需要设置选项 NERDTreeQuitOnOpen。然后,当您处于要打开文件的窗口中时,只需打开 NERDTree 即可。
NERDtree will open a file in the previous window if you press o or enter. You can open it in a split of the previous window by pressing i, or in a vertical split by pressing s.
It sounds like you have Ctrl-H mapped to Ctrl-W h. The trick to not having NERDtree open the file into a window that is adjacent to the NERDTree window is to not have the adjacent window be the previous window.
To achieve this, toggle the NERDTree window closed. (:NERDTreeToggle, or whatever your mapkey is to toggle NERDTree). Then move to the appropriate window you want to open the file in. Then toggle NERDTree open again. Now you can open the file in the previous window that you were in using o or enter... or in splits using i or s.
To save having to toggle the NERDTree window open/close, you may want to set the option NERDTreeQuitOnOpen. Then you just need to open NERDTree when you're in a window that you intend to open a file into.
我通常使用
:NERDTreeFind
来从右侧分割窗口移动到最左侧的 NERDtree。此命令显示 NERDtree 窗口中当前打开的文件。据此,上一个窗口就是右侧的窗口。当然,只有当您要打开的文件在目录树中靠近已打开的文件时,这才可以方便地工作。
为了快速访问
:NERDTreeFind
,我将其映射到~/.vimrc
中的Ctrl + m
:I usually use
:NERDTreeFind
in order to move from the right split window to the NERDtree on the very left.This command shows the currently open file within the NERDtree window. Based on this, the previous window is the one on the right side. This of course only works conveniently if the file you want to open is close in the directory tree to the file already open.
To quickly access
:NERDTreeFind
, I mapped it toCtrl + m
in my~/.vimrc
: