title: Indenting comments to match code in vim
body: <p>I do all my coding in vim and am quite happy with it (so, please, no "use a different editor" responses), but have an ongoing annoyance in that the smartindent feature wants to not indent comments beginning with # at all.  e.g., I want</p>
  
  <pre><code>  # Do something
    $x = $x + 1;
    if ($y) {
      # Do something else
      $y = $y + $z;
    }
  </code></pre>
  
  <p>instead of vim's preferred</p>
  
  <pre><code># Do something
    $x = $x + 1;
    if ($y) {
  # Do something else
      $y = $y + $z;
    }
  </code></pre>
  
  <p>The only ways I have been able to prevent comments from being sent to the start of the line are to either insert and delete a character on the line before hitting # (a nuisance to have to remember to do every time) or turn off smartindent entirely (losing automatic indentation increase/decrease as I open/close braces).</p>
  
  <p>How can I set vim to maintain my indentation for comments instead of sending them to the start of the line?</p>