Code Comment – gedit Plugin

đź“… May 22, 2015
gcc01Gedit is an excellent text editor that supports themes and plugins. One such plugin useful for programming is called Code Comment, and it allows you to comment and uncomment highlighted lines of code at once.


The Code Comment plugin is available from the Ubuntu repository as part of a bundle of additional gedit plugins. Assuming that gedit is already installed on your Linux system, install the gedit-plugins package from Synaptic or the command line.

sudo apt-get update
sudo apt-get install gedit-plugins

Close and restart gedit (if open) and go to Edit > Preferences > Plugins tab. You will see many new plugins added to the default list.

A list of all available plugins will appear. A plugin must be enabled in gedit before use. Scroll down to find Code Comment and check its checkbox. Close, and Code Comment will be available for use from gedit’s Edit menu.


Gedit plugin list from Edit > Preferences > Plugins tab. Highlighted is the Code Comment plugin. Check it to enable.


To comment, highlight a block of code and choose Edit > Comment Code. The selected code will be commented with line-level comments, not block-level comments.


HTML file. We want to comment lines 15-20.


First, highlight lines 15-20.


Now, select Comment Code from the Edit menu. HTML comments are applied. To uncomment, highlight the lines and choose Uncomment Code from the Edit menu.

Comments are language-dependent. For example, HTML comments (<!– –>) will be used in HTML files, Python comments (#) will be used in Python codes, and JavScript single-line comments (//) will be used in JavaScript files.


Here is a snippet of Python code. Let’s comment lines 63-74.


Highlight and comment. It’s that simple. Notice that gedit automatically inserts the correct comment characters depending upon the detected source code. Since this source file is Python, Python comment characters are used. Even comments are commented further.

Keyboard shortcuts are also available:

  • Ctrl + M           Comment Code
  • Shift + Ctrl + M   Uncomment Code

This is a useful gedit plugin that is worth experimenting with.


  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: