Last Updated: September 29, 2021
·
3.774K
· badunk

Fastest way to comment out a block of code in vim

Given this code that you want to comment out

var someFunction = function(){
    some code I want
    to
    comment
    out
}

And your cursor is at the first {, you can type

  1. v visual editor mode
  2. % go to the matching }
  3. :norm I// insert inline comments at the beginning of each line
// var someFunction = function(){
    // some code I want
    // to
    // comment
    // out 
// }

2 Responses
Add your response

I suggest to also look into the following vim plugin. https://github.com/tomtom/tcomment_vim

over 1 year ago ·

I think that plugin will change my life - thanks!

over 1 year ago ·