0

I have some windows opened in my vim (which were created using the split :split / :vsplit command). I also have a quickfix list populated with a list of files (which is the result of a grep command that I loaded using :cf command and then :copen).

When I have my cursor on one of the filenames listed in the quickfix, I can press Enter to open it. It will open its content as a new buffer and display it in one of the available windows. However, I would like vi to load this file in a specific window. Right now, it is using a window that I wanted to keep untouched. How to do that?

Baumann
  • 1,009
  • 10
  • 18

2 Answers2

0

From :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.

The behaviour of <Enter> can be further altered with :help 'switchbuf' but there is no explicit and determinist way to tell Vim to use a specific window.

romainl
  • 158,436
  • 18
  • 236
  • 264
0

Kind of :1windo e Ctrl-RCtrl-FEnter where "1" is target window number.

If it seems too long to type then define some buffer-local mapping in ~/.vim/after/ftplugin/qf.vim as usual.

Matt
  • 11,089
  • 1
  • 10
  • 19