title: Vim command to comment out a selection of lines?
body: <p>Say I have a bunch of lines:</p>
  
  <pre><code>@Override
  public void draw(Graphics g) {
      g.setColor(Color.MAGENTA);
      g.fillRect(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
      g.setColor(Color.BLACK);
      g.drawRect(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
  }
  </code></pre>
  
  <p>When I want to comment them out with <code>//</code> (i prefer line comments instead of block comments), what I do is:</p>
  
  <ul>
  <li>Place the cursor infront of the <code>@</code> symbol</li>
  <li><code>Ctrl-V</code>: Switch to enter block-select mode</li>
  <li>Select the column down to the <code>}</code> closing parenthesis using multiple hits of <code>j</code></li>
  <li><code>Shift-I</code>: to enter block-insert</li>
  <li>Type <code>//</code></li>
  <li><code>ESC</code> to excit</li>
  <li><code>Enter</code> to finish the command</li>
  </ul>
  
  <p>--> The lines are now commented out.</p>
  
  <p>Is there an easier way where I don't need to do the block-select? I found I can use a substitution like <code>:'&lt;, '&gt;s/^/\/\///g</code> but this has two problems:</p>
  
  <ol>
  <li>Its very clumsy and error prone to type (multiple forward and backward slashes need to be
  escaped)</li>
  <li>It places the comment symbols (<code>//</code>) at the beginning of
  the line (position 0), not at the position where the first character
  of that line was (so indentation is lost).</li>
  </ol>
  
  <p>How can I insert <code>//</code> on the selected lines at the position of the first character of each line using Vi?</p>