Video icon 64
Learning to code? Skill up faster with our practical video courses. Start your free trial today.

Vim Essential Plugin: tComment

This post is part of a series called Vim Essential Plugins.
Vim Essential Plugin: Markdown to HTML
Vim Essential Plugin: NERDTree

The tComment Vim plugin serves one purpose: to help you toggle comments in your code as quickly as possible. I'll show you how easy it is to use in this quick tip.


This utility plugin is a cinch to use - mostly because it performs only a single task. To comment a line of code, press ctrl _ ctrl _. Alternatively, if you wish to toggle multiple lines, select them in visual mode, and, again, press the trigger sequence: ctrl _ ctrl _

You can also use the shortcut gcc to comment a single line at a time. If you'd instead prefer to comment a single word, a few letters, or any other motion, use gc{motion}. For example, to comment the first word on a line, I could type: gcw, or, for the first three words: gc3w.