如何设置 window Vim 将选择显示从 quickfix 列表中选择的文件

How to set which window Vim will choose to display a file selected from quickfix list

我在 vim 中打开了一些 windows(它们是使用拆分 :split / :vsplit 命令创建的)。我还有一个用文件列表填充的快速修复列表(这是 I loaded using :cf command 然后 :copen 的 grep 命令的结果)。

当我将光标放在 quickfix 中列出的文件名之一上时,我可以按 Enter 将其打开。它将作为新缓冲区打开其内容,并将其显示在可用 windows 之一中。但是,我希望 vi 在特定 window 中加载此文件。现在,它正在使用我想保持不变的 window 。怎么做?

来自:help quickfix-window

You can use ":.cc" to jump to the error under the cursor.
Hitting the <Enter> key or double-clicking the mouse on a line has the same
effect.  The file containing the error is opened in the window above the
quickfix window.  If there already is a window for that file, it is used
instead.  If the buffer in the used window has changed, and the error is in
another file, jumping to the error will fail.  You will first have to make
sure the window contains a buffer which can be abandoned.
                    *CTRL-W_<Enter>* *CTRL-W_<CR>*
You can use CTRL-W <Enter> to open a new window and jump to the error there.

<Enter> 的行为可以用 :help 'switchbuf' 进一步改变,但是没有明确和确定的方式告诉 Vim 使用特定的 window。

种类 :1windo e Ctrl-RCtrl-FEnter where “1”是目标 window 数字。

如果打字看起来太长,那么像往常一样在 ~/.vim/after/ftplugin/qf.vim 中定义一些缓冲区本地映射。