In vim, how do I choose which window to load a quickfix item?

6

1

I routinely have 4 windows, split into a 2x2 grid. When I run a command that populates the quickfix, the first matching location is opened in the current window. But if I choose a QF location that isn't already loaded, it always seems to open in bottom-right-hand window.

Is there a way to make it load in a different window? Specifically, is there a way to make it load in the last window I was in - i.e. the window that "CTRL-w p" would take me to?

Kelvin

Posted 2013-08-15T20:36:15.827

Reputation: 387

Answers

8

Take a look at QFEnter vim plugin. It opens a item in the 'wincmd p' window when hitting enter or double-clicking on the quickfix item. Actually, it's my plugin :)

yssl

Posted 2013-08-15T20:36:15.827

Reputation: 96

Just downloaded the plugin. Perfect. Simply opens the window in the last focused pane. All I needed, because I generally use 2 vertical panes side-by-side for comparing code. – Charlie Dalsass – 2019-05-25T15:23:55.133

2

From :help quickfix.txt:

In the quickfix window, each line is one error. The line number is equal to the error number. You can use ":.cc" to jump to the error under the cursor. Hitting the 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.

I don't think you'll be able to avoid creating a custom mapping.

romainl

Posted 2013-08-15T20:36:15.827

Reputation: 19 227

Thanks for the info. I guess I can first switch to the window I want, then use BufExplorer to choose the buffer that quickfix loaded in the window I didn't want. – Kelvin – 2013-08-16T16:08:43.013

0

set switchbuf+=uselast

if you want to load the quickfix item into the previously used window.

user1135286

Posted 2013-08-15T20:36:15.827

Reputation: 1