While normally an OSX and TextMate user, of late I’ve had need to borrow laptop running Ubuntu 8.04, so obviously TextMate has been out of the question. While the machine is powerful enough to run Eclipse (thus RadRails) or NetBeans, I wanted something simple and quick. As it turns out, Ubuntu 8.04’s Gnome 2.22 comes with gedit, which has a couple of pretty simple plugins that will make use for Rails development a little easier, but it needs a tiny final push to round it off.
First off, pop open the gedit preferences (the Edit menu, then Preferences). For programming basics you’ll want to turn on Display line numbers on the first preferences tab (under View), otherwise when you get Rails errors you won’t be able to find where they were. The next small thing worth doing is the Rails convention of using a tab width of 2 and inserting spaces instead of tabs, which you’ll find on the Editor section - oh, you’ll also want to Enable automatic indentation otherwise you’ll drive yourself crazy. One other small thing I do here is on the Fonts & Colors section I select the Oblivion color scheme, I find the darker background with the colored text to be easier on the eyes.
The fun really begins when you go to the Plugins tab, you’ll want to activate the File Browser Pane, Indent Lines, Snippets and Tag List plugins, but for good measure I also activated Change Case, Insert Date/Time, Modelines, Sort and Spell Checker, though you can skip those if you want.
At this point you’ll be able to browse through the file pane, find your project, then double-click on the main directory to turn the file pane’s focus on just your project, making it behave kinda like TextMate. You’ll also get syntax highlighting on all .rb files, which is all controllers and models.
However, there’s still something missing - no syntax highlighting on rake, ERb or RJS files - lets fix that. The rather simple fix involves tweaking some core Gnome files in the /usr/share/gtksourceview-2.0/language-specs directory to add detection for these extra files. So, in order to do this, pop into terminal and run the following commands:
sudo nano /usr/share/gtksourceview-2.0/language-specs/ruby.lang
Once the editor shows up, after completing the usual sudo login process, go down to the line that says:
<property name="globs">*.rb</property>
and change it to:
<property name="globs">*.rb;*.rake;*.rjs</property>
Next off:
sudo nano /usr/share/gtksourceview-2.0/language-specs/html.lang
Once again, search for the line that says:
<property name="globs">*..html;*.htm</property>
and change it to:
<property name="globs">*.html;*.htm;*.erb;*.rhtml</property>
And that’s all there is to it. Enjoy.
Share this post