Comment Code Section In Vim

For Commenting code in Vim

  • First, go to the first line you want to comment, press Ctrl V. This will put the editor in the VISUAL BLOCK mode.
  • Then using the arrow key and select until the last line
  • Now press ShiftI, which will put the editor in INSERT mode and then press #. This will add a hash to the first line.
  • Then press Esc (give it a second), and it will insert a # character on all other selected lines.
Edit this page on GitHub