Create the file in
$HOME/vimfiles/ftplugin/qf.vim if you are on Windows) with the following contents:
" Only do this when not done yet for this buffer
wincmd p " go to original window
wincmd p " back to quickfix window
The ftplugin files are executed whenever the filetype is set for a given file buffer (quickfix and location window has the filetyp
Using the filetype plugin files instead of autocmds avoids cluttering your vimrc.
You can find more details at
:help 43 and Vim FAQ 26.8.
The check on
b:did_ftplugin is necessary to allow disabling it if necessary and to avoid loading it twice (see
let b:did_ftplugin = 1 is omitted from this file because the intent of this file is to increment the default filetype plugin for quickfix, and not override. If this line was added then the settings at
$VIMRUNTIME/ftplugin/qf.vim would be skipped, as explained at