title: How to create a key map to open and close the quickfix window in Vim
body: <p>If I use <code>:lopen</code>, Vim opens the quickfix window, and if I use <code>:lcl</code> on the window with errors (or the quickfix window itself), it closes it. </p>
  
  <p>What I want to do in my <code>.vimrc</code> is to create a map that opens the quickfix like this:</p>
  
  <pre><code>nnoremap &lt;F2&gt; :lopen 10&lt;CR&gt;
  </code></pre>
  
  <p>but when I press <kbd>F2</kbd> again it closes it using <code>:lcl</code>. </p>
  
  <p>Is there a way to know if the quickfix window is open and then execute the <code>:lcl</code>? </p>