Dr Nic

Post-Halloween RadRails trick – all TextMate snippets available

Textmate Snippets to Radrails

HTML snippets
Ruby snippets

I tease myself with things I can’t have – like watching TextMate demo videos. One wonderful video shows a test-driven design demonstration by James Edward Gray II where he used Textmate snippets to generate the various assert statements. For example:

ase => assert_equal(expected, actual)
asn => assert_nil(instance)
asm => assert_match(/expected_pattern/, actual_string)

I’d been using Corban Brook’s templates but they didn’t include any assert or migration templates. And I wanted them without having to spend $3049 on TextMate [1]

This made me cranky

Solution 1: Learn Emacs. Setting up Emacs with all the modules you’ll need is a non-trival exercise. That is, put aside a day or so and don’t expect to be finished when time runs out. Plus, a version of GNU Emacs for Windows hasn’t been released since 2005. Not a lot of OSS love there.

Solution 2: Offer to build Textmate for Windows. I’m sure I read once that the Textmate author was open to porting of Textmate to Windows. That must be the past, because their website claims very strongly that there will never be a port:

countless requests for both a Windows and Linux port, but TextMate remains exclusive for the Mac, and that is how we like it!

That’s just lazy if you ask me.

Solution 3: Port Textmate’s snippet libraries (bundles) over to RadRails. Textmate has a more powerful syntax for its snippets than RadRails has for its templates (a limitation inherited from Eclipse), but SUCCESS! On the 31st of October – the day when Textmate was lauded around the blogosphere for its Halloween theme, I ported all their snippets into RadRails. OoooOOOOHHH spooooky.

You can now access the latest and greatest in templates/snippets for Radrails, for Ruby/Rails and RHTML (or click on the yellow boxes at the top).


  1. Download the two template XML files.
  2. Open RadRails
  3. Go to Windows > Preferences > Ruby > Editor > Templates, to see the list of included templates
  4. Click on any template, and press Ctrl-A to select them all.
  5. Click on Remove, to delete them all
  6. Click Import…, select the file ruby-rr-templates.xml
  7. Change to Rails > Editiors > RHTML Editor > RHTML Templates
  8. Remove all the current templates
  9. Click Import…, select the file rhtml-rr-templates.xml
  10. Press Ok to close the dialog and you’re done

Too difficult? The next release of RadRails will include these new templates.

How to use templates/snippets?

You can peruse a textmate-snippets-cheat-sheet, but really, spend 20 minutes looking through the template lists in RadRails. The name of the template is the text you type into the editor to activate the template.

So, the name of assert_equals is ase. So, type ase and press CTRL-SPACE, and a list of options pops up. Press return on the selected option.

Want to see all available assert_* templates? Type as and CTRL-SPACE and there they are. Nifty.


The RadRails guys are going to host these templates to allow anonymous access to make submitting patches relatively easy (if you know how to wield SVN). In future perhaps there will be a nice website for collaboratively sharing and downloading updates to templates.

Templates for JavaScript and CSS

I’ve put in a request for adding template support for JS and CSS as I have ported the JavaScript+CSS bundles as well. We just need a UI to import them into RadRails.

[1] TextMate is 39 euros = $49 at the moment. Plus $3000 for a new Mac.

Related posts:

  1. Validate and Save your Ruby in TextMate – with secret Rubinus superpowers In some TextMate bundles, if you save a file it...
  2. Using Ruby within TextMate snippets and commands I didn’t know you could run Ruby within TextMate snippets....
  3. TextMate bundles for Merb If you are using TextMate (OS X) or E Text...
  4. Writing C extensions in RubyGems using newgem generators (plus a free TextMate bundle) Already know C extensions in RubyGems? Cool – then just...
  5. Rails 2.0 TextMate bundle – Tasty Tidbit – respond_to and view navigation The new release of the Rails TextMate bundle is coming...

75 Responses to “Post-Halloween RadRails trick – all TextMate snippets available”

  1. Tony says:

    Really usefull ! I can’t use a Mac and now I can provide my teammates an almost-good IDE with snippests. This is a good point to facilitate introduction of Rails in entreprise.

  2. Have these inside would be great (RHTML templates):

    if -> <% if (${cursor}) -%>
    end -><% end -%<
    elsif -> <% elseif (${cursor}) -%>
    erbe -> <%= ${cursor} %>
    erb -> <% ${cursor} -%>

    Sorrry for spamming! Damn!

  3. Dr Nic says:

    Any additional ideas for templates can be added at http://radrailstemplates.com

    But yep there is a whole lot that can be added to the RHTML template set.

  4. TextMate theme for RadRails…

    I was recently visiting with my friend Jayme and among other things, he told me about a theme that’s…

  5. [...] Get Eclipse Install Aptana extension Install ruby development tools extension Install RadRails extension Install subclipse extension Get TextMate snippets from http://drnicwilliams.com/2006/11/06/post-halloween-radrails-trick-all-textmate-snippets-available/ (These will be added to RadRails in the future) [...]

  6. [...] Post-Halloween RadRails trick Рall TextMate snippets available D̩veloppement RAILS: Les snippets de Textmate disponible pour RaidRails (tags: radrails rails rubyonrails snippets textmate templates ruby programming) [...]

  7. Patrick says:

    Have you already looked at InType? It’s a windows editor which wants to mimic TextMate.
    You can find it at http://intype.info/


  8. Dr Nic says:

    @patrick – yes, intype looks wonderful and can’t wait for more of the basic editor/ide features to be implemented (file explorer etc); but definitely keeping an eye on it.

  9. [...] Dr Nic’s TextMate snippets for RadRails [...]

  10. Carmelyne says:

    Thanks a bunch! This is extremely helpful.

  11. [...] So why? 1) The E-TextEditor homepage mentions TextMate six times. 2) A few people have converted TextMate’s snippets to operate in other editors. 3) There’s even a 200 page book about TextMate on the market. 4) If you’ve been floating around the various freenode Ruby and Rails related channels in the past couple of years, you’ll have undoubtedly seen at least several Windows or Linux users drop by raving about TextMate and lamenting their inability to buy a Mac. Yet.. they’ve ended up actually buying a MacBook (or similar) after several months, and continue to rave about TextMate (Jamie van Dyke is one example that sticks in my mind). [...]

  12. enric says:

    Thanks… I changed some of them to match the TextMate ones (like why are more than one named ‘mcol’ instead of ‘mcc’, ‘mrc’, ‘mac’, etc.?) but otherwise thanks for the work…

    I created a keyboard macro with AutoHotKey so I didn’t have to press Ctrl-Space->Enter. I mapped the key above tab to that action. So press Ctrl-Space if you don’t remember the full word, or type the exact name and then `, if you do…

    Anyway, if anyone cares, here is the AutoHotKey script…

    #IfWinActive ahk_class SWT_Window0
    `::Send ^{SPACE}{ENTER}

  13. inside says:

    Easy to find helpful information. Your web site is helpful. This will be my first time visiting. I will be back!

  14. juicy says:

    Okay, now can you write some for vim?

  15. Dr Nic says:

    @juicy – come on, you can do it :) Take the XML templates and do for it!

  16. [...] Nota: Los archivos ruby.xml y html.xml son los mismos que usa RadRails los cuales están basados en TextMate, estos archivos los modifique para que puedan usarse desde GEdit. [...]

  17. [...] My current editor of choice is RadRails (since it works pretty well in Linux and due to my Java-background in Eclipse), despite the slightly outdated version (last update in December, but I’m hoping, the new maintainers at Aptana will soon do something about that …). I googled a little bit and found that Dr Nic has already released both a TextMate theme and TextMate-like code templates for RadRails. Both seem to work pretty well. To finally make it look even more like TextMate, just download the font Monaco, go to “Window – Preferences – General – Appearance – Colors and Fonts” and set the Text Font to Monaco. [...]

  18. infrid says:

    I think this is awesome too – but you’re idea that a mac costs $3000 is pie in the sky, I’m afraid.

    Also netbeans kicks radrails butt some – so if you read this and thought.. dang – $3089 for a mac, well think again – a macbook which could run windows if you have to could cost you as little as £800 (what’s that $1600).. And it’ll be the best favour you do yourself.

    great blog btw – thanks!

  19. Dr Nic says:

    @infrid – the epilogue of my adventures with radrails and PCs is that earlier this year I bought a Macbook and now use TextMate :) But I’m glad these tools are still useful for radrails and hopefully aptana users.

  20. Seth says:

    How much did you end up spending for your MacBook? Were you close to your $3049 mark? Are you loving TextMate?

  21. Dr Nic says:

    @seth – I bought a Macbook 2G with 2G RAM and 80G HDD, and cost about 18000 swedish kronor or 2630 USD (including 3 yr warranty). It would have been cheaper in the US, but a Macbook Pro would have cost more.

    TextMate cost 39 Euro or 50 USD.

    Its a wonderful machine and I’m very glad I bought it, given that my previous laptop was on its death bed, and I need a new machine. The PC was still a decent development machine for the 1.5 years I did Rails development on it, though.

  22. Seth says:


    By the way, thanks for these snippets/templates. You just made my life TONS (or is it TONNES?) easier. I prolly had half of them already.

  23. black chippendale strippers…

    black chippendale strippers…