Vim Essential Plugin: tComment
videos

Vim Essential Plugin: tComment

Tutorial Details
  • Plugin: tComment
  • Screencast Length: 3 Minutes
This entry is part 6 of 8 in the Vim Essential Plugins Session
« PreviousNext »

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.


Usage

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.

Add Comment

Discussion 6 Comments

  1. Marcin says:

    Very useful, indeed. However, recently (btw. because of SASS session) I started working on my project with .scss files, and the default commenting is done by //. Can anyone help me how to change the default style to /* ?
    PS. Also how to set indentation to sw=4 and expandtab only for .scss files?

  2. Kien says:

    au BufRead,BufNewFile *.scss set ft=scss.css | set sw=4 | set expandtab

    Put it somewhere in your vimrc, ofc.

  3. rabbit says:

    hey jeffrey ,
    great series , thanks a lot for this . This really help me to become more productive and efficient on vim .

    BTW, I have a question and i know this is not the place to ask this type of question but i am just VERY curious ….!! In this screencast , there are a lots of icons of different app on right of your mac menu bar and most of them are unknown to me . I have recently switched to mac and so I am still in the middle of getting familiar with the developing environment , so if u can tell me what app are those then that would be a great help for me . I am assuming that all those apps are related to development work .

    Again sorry for asking this wired question here if it bother you .

  4. siros says:

    @1:13 you said you can comment out a ‘file’.

    and repeated it again with ‘you can select multiple-files’.

    where you should said Lines not files.

    Great plugin I see everyone trying to get the power of some textmate features with vim flavor .

    The later is driving me crazy by the way :D

  5. elegwance says:

    @0:35 How can focus to terminal at center like modal form?

    Very helpful post. thanks you.

  6. I’m still starting on using vim as my editor on web programming and you made my coding experience a lot easier because of this.

Add a Comment

To add a code snippet to your comment, please wrap your code like so: <pre name="code" class="html">YOUR CODE</pre>. You can replace the class name with "js," "css," "sql," or "php." If there are any "<" or ">" within your code, please search and replace them with: &lt; and &gt; respectively.