my usual setup is two vertically split windows. Lets say my cursor is in left window. When I vimgrep something, I would like for quickfix window to reuse already opened right window and automatically open there as a new buffer. Similary, if cursor was in right window, quickfix should open in existing left window. Is that possible? This is what I currently have. But it will open third window that I will have to close later. Thanks.
augroup quickfix
autocmd!
autocmd QuickFixCmdPost [^l]* call OpenQuickFixList()
augroup END
"open in vertical split and realign windows
function OpenQuickFixList()
vert cwindow
execute "normal \<C-w>="
endfunction