I know there is :copen
command which opens quickfix
window but it doesn't immediately switch to it(till it open). How can I wait for it to be sure my next commands in script would be executed in quickfix
?
1 Answer
This is the function that I use to ensure the Preview window is open and has focus. I like this window to be in the first tab, if you don't want that then your logic will vary accordingly.
I have a function that is mapped to hotkeys that fire off builds of different flavors; this function is called right before I execute :make
with my desired options.
function! EnsurePreviewWindow()
if ! &previewwindow " don't do this in the preview window
tabfirst
silent! wincmd P " jump to preview window
if ! &previewwindow " if we still aren't there...
0tabnew
setlocal switchbuf=useopen
execute "copen" (&lines / 3)
set previewwindow
endif
silent! wincmd p
endif
endfunction
copen
,set modifiable
,put='abcde'
. I then opened vim, sourced that script file, and observed the expected result that the quickfix window contained the lineabcde
.