gedit: Add Python / C++ Autocomplete Support

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

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

Resources:

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.