Here at MetaSpring, we’re avid fans of the TextMate text editor because it makes developing web apps a breeze through the use of its hotkeys, snippets, and bundles.
TextMate comes with a plethora of basic language bundles – all of which come with their own set of custom hotkeys and snippets designed specifically for that language. These hotkeys and snippets can be customized for your preferences or you can even make your own.
At MetaSpring, we work predominately with Ruby and would like to share a few of the TextMate helpers that have made us all much more efficient developers. The following hotkeys and snippets can be found in the Ruby bundle, unless otherwise noted.
Helpful Hotkey Commands
The following commands can be found and managed by going to Bundles >> Bundle Editor >> Edit Commands.
Control + Shift + E will execute a line or block of highlighted ruby code. The response will be outputted right after the executed code. This is extremely useful for testing Ruby syntax without having to switch to the IRB console.
Control + Shift + V will validate the syntax of your Ruby file. Try using this before running unit tests or reloading the server, it can save you tons of time spent repairing small syntax errors.
Command (⌘) + R will execute the file you are currently working on. One of our favorite features of this command is that it will also run RSpec tests if the file you have open is a spec file.
Convenient Snippets
The following snippets can be found or added to your TextMate environment by going to Bundles >> Bundle Editor >> Edit Snippets.
Hitting tab after entering a colon will produce a hash pair like :key => "value"
Control + L will produce a hash rocket with proper spacing =>
If you use Rails or Merb, you’ll most likely refer to a params[:x] variable frequently throughout the development cycle.
Control + P will output params[:id] where “id” is selected for editing.
Note: This snippet is included in both the Rails and Merb bundles.
Control + Shift + B sets up a comment block and allows you to enter the comment you want; a second tab gets you coding again.
Note: This snippet is included in the Source bundle.
Here’s an HTML snippet we made to make creating anchor tags a cinch.
Hitting Tab after entering an a outputs <a href=""></a>. You can then enter the link URL and hit tab to enter the link text.
To set this up in your own TextMate environment, create a new snippet with the following settings:

Other Useful TextMate Bundles
With bundles for almost every programming and scripting language, the above examples are only a small sampling of the magic that TextMate is capable of. For more Ruby-relevant functionality, you might check out some of the following add-on bundles:


Design & Branding


May 20th, 2009 at 3:46 am
Textmate sounds like an awesome text editor, will definitely begin using it!
Cheers
May 25th, 2009 at 4:58 am
What does a text editor do, I mean does it simply extract text as you pleases or is it something that deals with coding? hhmm.. I’m a bit confuse about it.
May 27th, 2009 at 2:06 pm
@Charlotte SEO Company,
TextMate is a general-purpose GUI text editor for Mac. This editor allows you to write code, have your code highlighted (depending on the language you are working in), and provides additional development tools that integrate right into the editor. It has become the standard editor for developers using a Mac.