How to toggle comments using Vrapper

Using plugins, a block of code can be commented or uncommented in Vim using the command gc. Similar capability to toggle comments is available in Vrapper, but only in the language specific addons.

For example, if you are working with Eclipse CDT (C/C++), then install the Vrapper – C/C++ Extensions plugin to get this capability.

Tried with: Vrapper 0.54.0, Eclipse CDT 4.4.2 and Ubuntu 14.04

Commentary plugin for Vim

One of the most frequent operations I do in source code is to add, remove or toggle comments over blocks of code. I used to use the TComment plugin for Vim to do this.

Recently, I discovered Tim Pope’s Commentary plugin that does the same. I have switched to it since its code is smaller and simpler. The only operation I use is to visually mark the lines and gc to toggle commenting on it.

Tried with: Vim 7.4 and Ubuntu 14.04

TComment plugin for Vim

The TComment plugin is a must-have for every Vim user. It does just one thing and does it well: comment or uncomment lines of code in any language.

First clone the plugin from its github homepage and install it using Pathogen.

To comment or uncomment a few lines of code, mark the lines in visual mode. You can do this by pressing Shift-V on the first line and then moving down by pressing j. After that, press gc to comment or uncomment those lines. That is it! 🙂

Tried with: Vim 7.3 and Ubuntu 12.04 LTS

Comments in the hgrc file

The hgrc is the primary configuration file of a Mercurial repository. It may sometimes be useful to document some of its contents with comments.

The hgrc file follows the INI file format. In the INI file format, a line beginning with a semicolon (;) character is a comment line. So, this can be used in a hgrc file to write comments.

Some software that read INI files also allow the hash (#) character to begin a line of comments. Mercurial supports this too in the hgrc file as a comment line.

Tried with: Mercurial 2.2.2 on Windows 7 64-bit