Search code examples
vimvim-quickfix

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


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?


Solution

  • 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.