Pimp my Gedit (Was: Textmate for Linux)

Gedit is the default text editor provided with Gnome in Ubuntu and other distro. It look very simple, but it extensible with plugins.
Here a list of some cool features and styles you can add it.

UPDATE: here is a Linuxcast video with gedit and the main features and shortcuts.

This Howto is for Gedit >= 2.20 for an older version take a look here.

Official plugins

Session Saver: you can save the status of the tabs/files opened
Snippets: use quicly the most useful piece of code
File Browser Pane: a mini file browser embedded in the editor
Code comment: a shortcut to comment your code. Many languages are supported

You can install them with:

sudo apt-get install gedit-plugins

Third Party plugins

Snapopen http://www.upperbound.net/snapopen/
Class Browser http://www.stambouliote.de/projects/gedit_plugins.html
Word Completion http://elias.hiex.at/gedit-plugins/

Unpack the files in ~/.gnome2/gedit/plugins
then open gedit and enable the plugins you need from Edit > Preferences > Plugins

Other plugins are avalaible on the wiki.

Rails 2 support with .erb highlight

The syntax highlight of .rhtml, .html.erb, .rjs,.. is avalaible with these easy steps:

wget http://robzon.kapati.net/rails/rhtml.lang && sudo mv rhtml.lang /usr/share/gtksourceview-2.0/language-specs/
wget http://robzon.kapati.net/rails/rails.xml && sudo mv rails.xml /usr/share/mime/packages
sudo update-mime-database /usr/share/mime

Thanks to: http://joslynesser.com/articles/3

Themes

Color scheme: darkmate (or another one)
Code Font: Liberation Mono 11
Window Font: Lucida Grande 9 (or another one)

Gedit with multiple windows

The default behavior of Gedit is to open a document in a new tab in the current window. If you need a new window, for instance to compare 2 sessions, you can run:

$ gedit --new-window

If can use nautilus-actions to have this shortcut in the menu.

Ruby interactive documentation

sudo apt-get install ri

Now you can easly access to the documentation from a console embedded in Gedit

Example

$ ri String.split

RSpec autotest in background

RSpec is a BDD testing framework for ruby, you can integrate it in different ways, one of the smartest is via ZenTest. Everytime you save a file the tests run in background.

sudo gem install rspec ZenTest
sudo apt-get install ruby-gnome2
wget http://grigio.org/files/ruby-libnotify_0.3.3-1_i386.deb && sudo gdebi-gtk ruby-libnotify_0.3.3-1_i386.deb

Then put .autotest in your home and create a simple project to test it.


# Rakefile
namespace :spec do
  task :autotest do
    require './spec/rspec_autotest'
    RspecAutotest.run
  end
end

# something.rb
# spec/something_rspec.rb
# spec/rspec_autotest.rb

Run in console 'autotest' and you will see the notification of the tests everytime you make some changes.

For more information see:
http://www.ikhono.net/2007/12/16/gnome-autotest-notifications
http://dcberner.blogspot.com/2007/10/ruby-libnotify.html

commenti

Kristofer

Great guide! Thank you.

Which theme are you using to get windows like that in the first screenshot? I looks really good.

x64 Argh!

I got gdebi installed (no -gtk) and now I have the problem that the deb file is for i386 and I'm running x64. Do you have an x64 version?

Thanks Phil

libnotify-ruby

That .deb was an unofficial package made by me, I don't have x64, but you can compile it from source.
See http://ruby-libnotify.rubyforge.org/

If you want the deb follow this bug:
https://bugs.launchpad.net/ubuntu/+source/libnotify/+bug/205528

This is fantastic!

Thanks for this I've been looking for how to pimp up gedit to make working with Rails easier. Another plugin you may want to add is one of the Search in folder or grep plugins. Also gdebi-gtk doesn't seem to be installed on my Intrepid Ibex install.

Liutauras

Awesome tutorial.
I get this error

/usr/lib/python2.5/site-packages/apt/__init__.py:18: FutureWarning: apt API not stable yet
warnings.warn("apt API not stable yet", FutureWarning)
/usr/lib/python2.5/site-packages/GDebi/GDebi.py:93: GtkWarning: gdk_window_set_cursor: assertion `GDK_IS_WINDOW (window)' failed
self.window_main.set_sensitive(False)

then execute this command:

wget http://grigio.org/files/ruby-libnotify_0.3.3-1_i386.deb && sudo gdebi-gtk ruby-libnotify-0.3.3/ruby-libnotify_0.3.3-1_i386.deb

Any ideas?
Thanks for your help.
Liutauras

The correct command

is:
sudo gdebi-gtk ruby-libnotify_0.3.3-1_i386.deb

Alexandre da Silva

You can use some more plugins I made, such Smart Indent and Extract Partial for rails templates
there I have:

gedit-todo : A Todo List plugin that look for todo marks in source code like "# TODO: fix this", and list (Integrated with filebrowser)

gmate: A Plugin pack that includes:
Geminy
Snap Open
Smart Indent
Extract Partial (Rails Specific)
Find In Files (FileBrowser Integration)
TrailSave (Remove trailing spaces before save any file)
Colorschemes (Including Railscasts Clone for Gedit)

GTKSourceview2 Improvement for rubyists here

Alexandre

Luis

I created this cheat sheet for rails development in gedit:
http://www.scribd.com/doc/6299312/Gedit-Cheat-Sheet-for-Rails-Development

Indenting

What do you do for auto indenting?

The default indentation in gedit doesn't automatically adjust according to the code block.

Snippets

It's not indentation but the snippets plugin

very cool

That's pretty cool...never knew Gedit could do that. But customized VIMX11 (GVIM) will do much of the same. See: http://www.alexyoung.org/articles/show/12/vim_for_textmate_fans and others. The omni-complete feature is pretty neat. Works great with Ruby.

Nice.

I've been using e-TextEditor and this is what I'm missing with this setup (first impressions):
* The snapopen plugin dies for 3-5 seconds because it parses vendor/ in a rails project. It would be nice with a way to ignore paths and files in the file browser and search. As they are independent plugins this might be hard to do reliably.
* Textmate bundles?

Recommended patch:
Change the number of letters that are needed before snapopen searches, in "snapopen/__init__.py", line 122.

Thanks for the tips :).

Simply amazing!

Many thanks...

three words

I LOVE YOU
:D

Link non funzionanti?

Ciao, complimenti per la guida - in effetti Gedit potrebbe tranquillamente sostituire TextMate, senza bisogno di IDE assai più complesse.

Ho visto che però i link dei file di robzon.kapati.net non funzionano. Qualcuno potrebbe fornire dei link alternativi, per favore?

Grazie mille, ciao a tutti!

Adesso sembrano andare

Adesso sembrano andare

plugins?

I think you mean gedit-plugins and not gnome-plugins

thanks

typo fixed :)