gedit: Add Python / C++ Autocomplete Support

by on September 12, 2009 · 12 comments· LAST UPDATED September 12, 2009

in , ,

How do I add Autocomplete support to gedit text editor under Linux Gnome desktop operating systems?

gedit is a general purpose UTF-8 compatible text editor for the GNOME desktop systems. gedit is well known for its simplicity and ease of use. You can easily edit various scripting and programming languages source code with gedit.

It is the default text editor for GNOME. gedit comes with a flexible plugin system allowing to dynamically add new features. A number of plugins are included in gedit itself, with more plugins in the gedit-plugins package and online.

Install plugins

Under Debian / Ubuntu Linux you can type the following command to install commonly used plugins:
$ sudo apt-get update
$ sudo apt-get install gedit-plugins

To configure plugin open gedit and visit Edit > Preferences > Plugins Tab

Fig.01: Gedit - Enabling / Disabling a Plugin

Fig.01: Gedit - Enabling / Disabling a Plugin

How Do I Enable a Plugin?

To enable a gedit plugin, perform the following steps:

  • Choose Edit ▸ Preferences.
  • Select the Plugins tab.
  • Select the check box next to the name of the plugin that you want to enable.
  • Click Close to close the Preferences dialog.

Step For Disabling a Plugin

A plugin remains enabled when you quit gedit. To disable a gedit plugin, perform the following steps:

  1. Choose Edit ▸ Preferences.
  2. Select the Plugins tab.
  3. Deselect the check box next to the name of the plugin that you want to disable.
  4. Click Close to close the Preferences dialog.

Add Python / C++ Autocomplete Plugin

Grab the latest version of Autocomplete plugin here. Unzip / untar the ball:
$ unzip nagaozen-gedit-plugin-autocomplete-9e7664759c9486f6cd402f89bedd7a3488328580.zip
Sample Outputs:

Archive:  nagaozen-gedit-plugin-autocomplete-9e7664759c9486f6cd402f89bedd7a3488328580.zip
9e7664759c9486f6cd402f89bedd7a3488328580
   creating: nagaozen-gedit-plugin-autocomplete-9e7664759c9486f6cd402f89bedd7a3488328580/
  inflating: nagaozen-gedit-plugin-autocomplete-9e7664759c9486f6cd402f89bedd7a3488328580/README.md
  inflating: nagaozen-gedit-plugin-autocomplete-9e7664759c9486f6cd402f89bedd7a3488328580/autocomplete.gedit-plugin
   creating: nagaozen-gedit-plugin-autocomplete-9e7664759c9486f6cd402f89bedd7a3488328580/autocomplete/
  inflating: nagaozen-gedit-plugin-autocomplete-9e7664759c9486f6cd402f89bedd7a3488328580/autocomplete/__init__.py

List files:
$ cd nagaozen-gedit-plugin-autocomplete-9e7664759c9486f6cd402f89bedd7a3488328580
$ ls -l

Sample Outputs:

total 12
drwxr-xr-x 2 vivek vivek 4096 2009-05-16 05:01 autocomplete
-rw-r--r-- 1 vivek vivek  594 2009-05-16 05:01 autocomplete.gedit-plugin
-rw-r--r-- 1 vivek vivek 2107 2009-05-16 05:01 README.md

Install Autocomplete Plugin

Type the following commands:
$ mkdir ~/.gnome2/gedit/plugins/
$ cp -avr * ~/.gnome2/gedit/plugins/

To enable a gedit autocomplete plugin, perform the following steps:

  • Choose Edit ▸ Preferences.
  • Select the Plugins tab.
  • Select the check box next to the name of the Autocomplete plugin.
  • Click Close to close the Preferences dialog.

Now start writing code and you should see the popup autocomplete. Press [Enter] key to accept the completion.

Fig.02: Autocomplete in Action

Fig.02: Autocomplete in Action

Resources:

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 12 comments… read them below or add one }

1 Jaysunn September 12, 2009 at 12:50 pm

Great tip,

I was unaware that gedit was capable of this. I will be sure to install and learn from it.

Thanks Alot,

Jaysunn

Reply

2 shashidhar September 12, 2009 at 2:53 pm

Good one,

I too don’t know that gedit supports this kind of feature through plugins.

Reply

3 spaceyjase September 12, 2009 at 6:32 pm

Great article; wasn’t aware gedit could do this so a big thank you!

“Select the check box next to the name of the Autocomplete plugin.”

It was called ‘Python Code Completion’ in the plugin list :)

Reply

4 arunkumar September 13, 2009 at 10:37 am

Great to know about this feature in gedit

Reply

5 kalanjali October 3, 2009 at 3:35 pm

it’s not working
i tried it on eswecha/debian version

Reply

6 S. Nilesh (www.itech7.com) October 9, 2009 at 5:21 pm

great feature. i wasn’t aware of this plugin.

Reply

7 nagaozen December 22, 2009 at 3:08 am

XD thanks for highlighting my autocomplete plugin. Just some notes:

In “Grab the latest version of Autocomplete plugin here. Unzip / untar the ball:” – Autocomplete link goes to pycomplete (which is not the one picture is showing)

Reply

8 BuZain March 21, 2010 at 7:51 pm

Thanks for the autocomplete installation steps. I’ve just started coding python after a long hiatus and this feature is a great support. BTW, the latest version of the plugin has an install script that does all the magic.

Reply

9 patrick November 4, 2010 at 2:54 pm

Thank you for this plugin – it is great!

Reply

10 daniel November 6, 2010 at 11:00 am

Well, this autocompletion is useless if all it proposes are names of objects already used in the source code. I’m still struggling with finding an autocompletion plugin that would be aware of all installed python modules and be able to propose those. Or am I missing something?

Reply

11 Vinicius July 29, 2011 at 5:16 pm

I can’t use the autocompletion plugin because it doesn’t have a python.json into lib folder, only asp.json… what do I do to enable python autocompletion with this plugin?

Reply

12 Nicolas September 27, 2011 at 6:23 pm

Hi everyone, I have a problem with my Mac os x Snow Leopard: I follow every step, but the Plugin isn’t at the panel in Preferences…can somebody help me?

Thanks,

-Nico

Reply

Leave a Comment

Tagged as: , , , , , , , , ,

Previous Faq:

Next Faq: