Pages

Making TextMate really dance with PeepCode

Since I've been learning Ruby on Rails I decided to take a step back and become as proficient as possible with TextMate. For those that don't know about it, TextMate is a fantastic editor available exclusively on the Mac platform. What makes it such a great editor is not that it has a wonderful editing surface or is able to save files faster than some other tool - from that standpoint it's not really all that different than TextEdit.

What make TextMate so cool is that it provides some great extensions - called Bundles - that can help you use it much as you might an Interactive Development Environment (IDE) in a complete development package. You can either create your own Bundles with language templates and helpers or you can choose from a large array of different Bundles that are freely available for TextMate.

There is a very good Ruby on Rails bundle that actually ships with TextMate. It has a number of features that can not only make quick work of class and definition tasks but can also run many of the scripts that help you build Rails applications. It really does turn TextMate into a powerful IDE for Ruby on Rails.

The challenge is learning all of these little shortcuts. You could literally spend days doing nothing but walking through all of the menus that are provided, trying to learn how it all works. It can be a bit overwhelming and lead you to just use TextMate as a simple text editor - but that's such a waste.

PeepCode Screencasts to the rescue
Travis Jeffrey commented in one of my earlier RoR posts that I should take a look at PeepCode's screencasts to help me learn Ruby a little more quickly. What they sell at the PeepCode site is a series of screencasts that not only can help you learn Ruby on Rails but also all of the TextMate extensions. At $9 a pop I figured I would give it a try.

The TextMate screencast is nicely produced and runs through virtually all of the features of the RoR Bundle. The pace is very fast and at times it can be a challenge to keep up - when I ran through it I kept one finger near the Pause (F8) button because I was either taking quick notes or trying out the keystrokes in a TextMate window.

While this sounds like a complaint it's actually a compliment. With the pace being that quick you can learn a lot in a very short period of time. I didn't find myself losing interest in this, even though the run time on it is just over an hour long. I already feel that I'm going to be much more productive after just running through it once.

Some times you can't appreciate the power of a tool until you've seen it in action under the hands of a professional and TextMate with the RoR Bundle is one of those.

Update Your Bundle Before You Watch
I learned the hard way that the RoR Bundle that ships with TextMate is a bit dated and does not leverage all of the Rails 2.0 enhancements and as a result does not match up with the Peepcode screencast. Before you try following along with this video you will need to run through a couple of steps:
  1. If TextMate is running, close it.
  2. Visit RailsBundle.com and download the latest RoR TMBundle file.
  3. The file is compressed - opening it will result in the creation of a Ruby on Rails.tmbundle file.
  4. Open that file - you will be asked by TextMate if you want to update the bundle. Click Update.
That's it - you will now have the latest Ruby on Rails bundle and it will match up with the examples in the screencast. You will also want to make sure that the scope for TextMate - which is at the bottom status bar just to the right of the column counter - reads Ruby on Rails.

One Last Little TextMate Tip - The To Do List Bundle
Most programmers love to document things that need to be optimized or repaired by placing small comments in their code. TextMate has a Bundle called TODO that will open a small window and display an organized list of items marked with comments containing TODO, FIXME and CHANGED. You can add more of these with standard regular expressions and they will be presented in your list. You can then click on the link provided in the list and jump to that point in the code.
If you are using TextMate as a glorified text editor do yourself a huge favor and take the time to learn the extensions for your language or file type. This is one of those things that will give you a huge return on your investment.

4 comments:

Cyclist At Large said...

Actually, IDE stands for 'Integrated Development Environment', meaning that you can do everything -- edit the code, run it, test it and debug it -- all from the environment.

Close enough, though. :)

David Alison said...

@Cyclist: This is a good point - a true debugger doesn't seem to be there. But with Rails in development mode all I need to do is save the files, flip to my browser and hit refresh and the changes are reflected. If I have to rake the DB I can actually do that with the TextMate bundle for Rails. It's really close.

exceptionz said...

You should check out the RubyAMP bundle which gives you some really nice Debugging and code navigation features. There's a video out on the web showing the bundle in action.

David Alison said...

@Exceptionz: Hadn't heard of that - thanks! For people interested here is a direct link to RubyAMP.