Praise for the Humble gedit

A rare case of the default option being surprisingly powerful.

I’ve been a fan of lightweight text editors for more than 10 years now. I started out on Emacs, drifted over to Vi(m) for a long stretch and then somehow settled into Textmate for the last couple of years. This week, since I’ve been bouncing from OS to OS, I’m checking in with a number of text editors that I’ve either never used or haven’t visited in a long time. Having been a KDE guy back in the day, gedit falls under the former category.

Fresh out of the box gedit’s not going to win many awards. It’s decent as far as default text editors go — loads quickly, tabbed windows, strong Unicode support, native (but buggy) SFTP support via embedded Nautilus bookmarks in the sidebar, &c. — but where it really shines is when you start to flesh out functionality with plugins.

Plugins

It was gedit’s complete lack of native regex search/replace that lead me to the gedit plugins page. There you’ll find a ton of great stuff: Browser Previews, HTML Tidy, Class Browsers, Auto-complete, and a pretty good Regex plugin.

All of the plugins are written in Python and writing your own is simple enough. In fact, you don’t even have to write a plugin to control gedit with Python.

The Python Console

gedit’s console is closed by default but if you go to View > Bottom Pane you can bring it up. Under the Python Console1 tab you should see:

You can access the main window through 'window' :
<gedit.Window object at 0x8591f7c (GeditWindow at 0x8144008)>

As you can probably tell, this gives you an enormous amount of control over the editor. You can check this plugin tutorial for a brief overview of the classes you have access to but if you want to be a little overwhelmed try dumping the window class with:

>>> for slot in dir(window):
... 	print slot

There’s a lot of stuff here and much of it self-explanatory and simple to use. Want to create a new tab and populate it with an empty document? Simple:

window.create_tab(0);

I’ve been playing around with the Python Console and I’m starting to view it as the colon operator in Vi(m). I guess I could just install the ViGedit plugin but that almost seems too easy.

Textmate without OS X

Textmate for Mac OS X has a pretty hardcore following — I’m counted as a fan — and it would appear there’s a growing contingent of developers looking to recreate the Textmate experience on Linux. I for one applaud these courageous souls that braved the “Why does everyone try to make Linux look like something else” whiners and whipped up some great docs for tricking out gedit:

Let the Text Editor Flame Wars Begin!

Now that I’ve got gedit duly loaded with plugins I’m probably going to be using it for awhile. If you’re not too attached to your .vimrc file you might want to give it a whirl.

I was going to whip up a text editor poll to get a sense of where everyone’s text editor allegiances lie but I figured it would be more democratic and flexible if everyone just posted in the comments. I’ll see if I can’t find my brass knuckles and see you there.

1 If you don’t see a Python Console tab, you’ll need to enable it in the plugin preferences. Go to Edit > Preferences, click on the Plugins tab and check “Python Console.”

Fatal error: Call to undefined function aa_author_bios() in /opt/apache/dms/b2b/linux-mag.com/site/www/htdocs/wp-content/themes/linuxmag/single.php on line 62