title: Vim: The "gq" Command to Hard-Wrap Comments, but Not the Code (even if no blank line in-between)
body: <p>My Vim configuration includes <code>set formatoptions=c,q,a</code>. I am completely annoyed with the following problem (<code>|</code> denotes cursor position, its exact position does not matter, as you probably know only the fact of its presence in this commented line matters):</p>
  
  <pre><code>" This is a long line which we would like to wrap. However, something sick is go|ing to happen if we hit "gqip" here!
  if has('win32') || has('win64')
    set runtimepath^=~/.vim
    set runtimepath+=~/.vim/after
  endif
  </code></pre>
  
  <p>Now we hit <code>gqip</code>:</p>
  
  <pre><code>" This is a long line which we would like to wrap. However, something sick is
  " go|ing to happen if we hit "gqip" here!
  if has('win32') || has('win64') set runtimepath^=~/.vim set
    runtimepath+=~/.vim/after endif
  </code></pre>
  
  <p>What it does is - it actually treats the whole thing as a single paragraph. (Yes, I know that separating with a blank line prevents this behavior, but it does not solve the problem!) What I would like it to be is indeed:</p>
  
  <pre><code>" This is a long line which we would like to wrap. However, something sick is
  " go|ing to happen if we hit "gqip" here!
  if has('win32') || has('win64')
    set runtimepath^=~/.vim
    set runtimepath+=~/.vim/after
  endif
  </code></pre>
  
  <p>In other words, it would be great if <code>gq</code> could somehow forget about the code and work only with comments.</p>
  
  <p><strong>BONUS:</strong> How to do this formatting (wrapping comments <strong>only</strong>) on the whole buffer in one shot? Because, ideally I would like to move that stuff to a special formatting hook for file saving.</p>