To comment out a block in vim, I enter visual mode with v or Control-v, select some lines, then hit I (Shift-i).

However, I takes me out of visual mode and into Insert mode (which makes sense, as that is what I usually does). So what am I doing wrong? How do I comment out a block?

1 Answer 1


It depends on the way you entered visual mode. If you used V for line based visual selections, I will only enter insert mode for the very first line. However when you used Ctrlv, I will also take you into insert mode for the very first line, but after you press Esc everything that was entered will also be copied to all the other lines of the selection.

From within visual mode, you can switch the different visual mode settings by pressing v for switching to characterwise visual mode, V to switch to linewise visual mode or Ctrlv to switch to blockwise visual mode.

  • Thank you. That worked. But I think that you mean Ctrl v rather than Ctl V. Could you please fix? Also, are the capitalizations of v and V (without Ctrl), particularly the first one, correct?
    – Joshua Fox
    Apr 22, 2020 at 7:28
  • 1
    The first V mentions linebased visual selection, so yes this is correct. Apr 22, 2020 at 9:04
  • 1
    @JoshuaFox Ctrl+v and Ctrl+V are the same. When the Ctrl key is pressed, typing the lowercase or uppercase key will result on the same keycode being generated. By convention, most documentation (including Vim's) tends to use uppercase more often than not in Ctrl+<key> sequences.
    – filbranden
    Apr 23, 2020 at 3:30
  • 2
    @filbranden while this is true for the traditional way console programs receive input, I am not sure this is in general true. So there might be ways for graphical programs to actually distinguish Ctrl-V from Ctrl-v. And I believe the new xterm-modify-otherkeys feature implemented by Vim can also distinguish this. Apr 23, 2020 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.