title: Quickfix & Preview window resizing
body: <p>Normally when quickfix window opens it changes the screen layout, but Vim restores
  it when that window is closed.</p>
  
  <p>But there is a situation where the layout restoration fails: when the
  preview window is open, vertical splits are presents and <code>:wincmd J</code> is executed
  in quickfix (or it is opened with <code>:botright copen</code>). In this case the size of
  preview window is changed.</p>
  
  <p>I came with a solution which I placed on ~/.vim/ftplugin/qf.vim,</p>
  
  <pre><code>  " Only do this when not done yet for this buffer
    if exists("b:did_ftplugin")
       finish
    endif
  
    " expand quickfix when there are vertical splits
    wincmd J
  
    func! RestorePreviewWindow()
       let l:quickfixHeight = winheight(0)
       wincmd p " include previous window on jump list
       silent! wincmd P  " jump to preview window
       if &amp;previewwindow " if we really get there...
          exe "resize " . (&amp;previewheight - l:quickfixHeight - 1)
          wincmd p " back to old window
       endif
    endfunc
    augroup quickfixClosing
       au!
       au BufDelete &lt;buffer&gt; call RestorePreviewWindow()
    augroup END
  </code></pre>
  
  <p>, but I was wondering if there is some better/simpler solutions to this
  problem.</p>