Commenting block of code in VIM

  1. Ctrl + v : Visual block
  2. Select first column of the block of code to comment
  3. Shift + I : moves cursor to beginning and enters insert mode
  4. Type the character which comments the line: # for python or // for c/c++
  5. ESC

To uncomment use visual block (Ctrl + v) to select the commenting characters and delete them by typing x.