Skip to content

Instantly share code, notes, and snippets.

@willi-dev
Forked from ultim8k/vim-multiline-comment.md
Created August 11, 2025 08:56
Show Gist options
  • Save willi-dev/f4b33fd5bdaf164626bb09b7109a30b2 to your computer and use it in GitHub Desktop.
Save willi-dev/f4b33fd5bdaf164626bb09b7109a30b2 to your computer and use it in GitHub Desktop.

Revisions

  1. @ultim8k ultim8k revised this gist Nov 4, 2016. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions vim-multiline-comment.md
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,6 @@ From: http://stackoverflow.com/questions/1676632/whats-a-quick-way-to-comment-un

    For those tasks I use most of the time block selection.

    Put your cursor on the first # character, press CtrlV (or CtrlQ for gVim), and go down until the last commented line and press x, that will delete all the # characters vertically.
    Put your cursor on the first `#` character, press `Ctrl``V` (or `Ctrl``Q` for gVim), and go down until the last commented line and press `x`, that will delete all the `#` characters vertically.

    For commenting a block of text is almost the same: First, go to the first line you want to comment, press CtrlV, and select until the last line. Second, press ShiftI#Esc (then give it a second), and it will insert a # character on all selected lines. For the stripped-down version of vim shipped with debian/ubuntu by default, type : s/^/# in the second step instead.
    For commenting a block of text is almost the same: First, go to the first line you want to comment, press `Ctrl``V`, and select until the last line. Second, press `Shift``I``#``Esc` (then give it a second), and it will insert a `#` character on all selected lines. For the stripped-down version of vim shipped with debian/ubuntu by default, type `: s/^/#` in the second step instead.
  2. @ultim8k ultim8k created this gist Nov 4, 2016.
    7 changes: 7 additions & 0 deletions vim-multiline-comment.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    From: http://stackoverflow.com/questions/1676632/whats-a-quick-way-to-comment-uncomment-lines-in-vim

    For those tasks I use most of the time block selection.

    Put your cursor on the first # character, press CtrlV (or CtrlQ for gVim), and go down until the last commented line and press x, that will delete all the # characters vertically.

    For commenting a block of text is almost the same: First, go to the first line you want to comment, press CtrlV, and select until the last line. Second, press ShiftI#Esc (then give it a second), and it will insert a # character on all selected lines. For the stripped-down version of vim shipped with debian/ubuntu by default, type : s/^/# in the second step instead.