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.”

Bryan Richard is the VP of Editorial and Infrastructure for Linux Magazine. Want to get in touch? Send him an email.

Comments on "Praise for the Humble gedit"

rlihm

I use VIM, gEdit (for Cut&Past work on LINUX) and TextMate (Mac).

The cool thing about TextMate is, that you have an editor with a very slim GUI and on the other hand a bunch of handy stuff that simply make your life easier. You can just focus on your work and don’t have to fight the editor first. TextMate is a life-time-saver!
Honestly … TextMate is one of the main reasons why sometime I use a Mac sometimes.

Thanks for the link collection Bryan!

Cheers
Robert

Reply
chavoux

I use mcedit (midnight commander) for most of my simple editing work. In the GUI I mostly use kate. I have tried VIM and EMacs, but the learning curve seemed a bit too steep for simple text editing.

I haven’t really used gedit, but knowing about the python interface might just get me to look at it again.

Cheers
Chavoux

Reply
dford

I agree with chavoux – Vi and EMACS are just too much hard work to use to edit a text file – I use ‘joe’.
david

Reply
dbayer

I’m one of those non-denominational text editors.

Vim has a bit of a learning curve, but with a cheat-sheet posted on my monitor I use it for all cli text editing. In the gui I’ve used gedit for a while and like it pretty well. Played with kate some, but don’t use it very much (for no particular reason). On Macs I use TextWrangler and on Windows I use PSPad. I’m all about the free stuff…

Reply
ageilers

“Having been a KDE guy back in the day, gedit falls under the former category.”

Well, actually, gedit would go with GNOME. KDE currently would be Kate or Kwrite . I can’t remember what editor came with KDE back when.

Reply
bryanjrichard

Yeah, that’s what I mean. I used to be strictly KDE so I never had an opportunity use gedit until this week. I don’t recall what the default editor was either in pre-2000 KDE. I’m pretty sure I just set the path to vi though.

Reply
bryanjrichard

The old joke about everyone’s first vi session rings pretty true. But after awhile you start to appreciate all of these ^’s (emacs) and :’s (vi).

Reply
beerse

When I started with unix about 20 years ago, vi already was a steep learning curve but it was there on every unix machine. The alternative at that time was emacs, which had a more relax learning curve but a steep installation curve as it was (and stil is) not available on every installation…

Then `vi` has some more advantages: If you know vi, specially the : commands, then you know `ed` (which effectively is what you use with the : commands) and you know all ed’s deriviates as `ex` and `sed`.

I see the regexp as available in ed is still unbeaten. It is the major reason why I keep comming back to the commandline to use vi.

btw: I’ve just seen a msWindows Powershell and W2008 presentation. I wonder if edlin is available, notepad still is there…

Reply
dewfy

The only reason I hate emacs – is a scrolling policy of large text. When your eye expects shifting line up, you get centring of this line on screen. It strange but I never meet workaround.

Reply
sharder

Hi,

I have had to use Vi a couple of times and each time I am completely lost.

I use Emacs a lot for programming and sometimes even for writing mails and copying them into my mail-program (it tends to die when you send the mail). I do not understand that anyone find the learning curve steep; isn’t this the Platonic ideal of an editor? ;-) You just have to start at a young age ;-)

Reply
bryanjrichard

Anyone having trouble with Vim’s learning curve might want to try installing Cream — it takes some of the sting out of the Vim command structure but doesn’t lose any of its text processing power. We just posted an article about it: Sweeten Your Vim with Cream.

Reply
pstahle

Depending on what I am doing I use vim (full, non vi compatible) or I will use jEdit. On a rare occasion I will pull out nedit and use that. I am kind of weird in that if I am used to editing certain types of files with a certain editor that is what I will feel most comfortable doing. For instance I have spent many years doing console editing of perl code from vim and feel uncomfortable editing/writing perl any other way. One of my pet peeves is all the distros that default to vim minimal, and have a lot of the great features of vim turned off…. that is just plain irritating….

Reply

Leave a Reply to chavoux Cancel reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>