This question already has an answer here:

In various editors one can mark a block of code and with a shortcut, comment it right away. Is there a possible way to do it in Vim without an extra plugin? If not, which plugin or script would you suggest?

marked as duplicate by Martin Tournoij, gon1332, Seth, johannes, bsmith89 Feb 4 '15 at 19:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


The best way that I found is using tpope's vim-commentary plugin. You're able to use the ctrl+v I# mentioned in the question linked to in the comment to the OP, but this will automatically work with different comment types with different languages.


From my answer over here:

I use scrooloose/nerdcommenter for this.

With this plugin you can visual select your lines and hit leader+c to toggle comments. Depending on the file type it will use different symbols for commenting.

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