Comment out and uncomment multiple lines in VIM

This simple procedure will comment multiple lines:

  • Go to first or last line of the intended area
  • Press CTRL-V for Visual Block
  • Go to the last or first line to select the intended area
  • Type    :s/^/#    and press enter

Obviously following the same logic we can uncomment a block with:

  • Go to first or last line of the intended area
  • Press CTRL-V for Visual Block
  • Go to the last or first line to select the intended area
  • Type    :s/^#/    and press enter

Not an easy one to remember so what do you do? You write it down somewhere, right?

Your thoughts

No comments

Add comment

* - required field

*




*