A random collection of Vim commands I've found to be useful.

Block comment

While I use @@ in my ~/.vimrc file, here is a way to do it "manually":

  1. Go to first line you want to comment, and (in normal mode) press 0 to go to beginning of line.
  2. Press Ctrl-v to enter visual block mode (not the same as simply pressing V.
  3. Press j to move down, and stop on last line you wish to comment.
  4. (Only the first character of each line will be highlighted.)
  5. Press c//<Esc>p, if the comment you want to add is //
  6. (for Python use c#<Esc>p)

Source: this underrated Stackoverflow post

To uncommment:

Simply use Ctrl-v to highlight the comments, and press x to delete them.

Alternative method:

There is another way:

  1. Go to first line you want to comment, and (in normal mode) press 0 to go to beginning of line.
  2. Press Ctrl-v to enter visual block mode (not the same as simply pressing V.
  3. Press j to move down, and stop on last line you wish to comment.
  4. (Only the first character of each line will be highlighted.)
  5. Press Shift-i (capital "i")
  6. Enter the characters to comment one line, e.g. # or //
  7. Press <Esc> key, and wait one second, and the comments will then appear.

However, the downside to this method is that there is a slight (one second) delay before the comment appears, which is why I prefer the first method. The reason I