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)
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.
- Download the two template XML files.
- Open RadRails
- Go to Windows > Preferences > Ruby > Editor > Templates, to see the list of included templates
- Click on any template, and press Ctrl-A to select them all.
- Click on Remove, to delete them all
- Click Import…, select the file ruby-rr-templates.xml
- Change to Rails > Editiors > RHTML Editor > RHTML Templates
- Remove all the current templates
- Click Import…, select the file rhtml-rr-templates.xml
- 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
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.
 TextMate is 39 euros = $49 at the moment. Plus $3000 for a new Mac.
- Validate and Save your Ruby in TextMate – with secret Rubinus superpowers In some TextMate bundles, if you save a file it...
- Using Ruby within TextMate snippets and commands I didn’t know you could run Ruby within TextMate snippets....
- TextMate bundles for Merb If you are using TextMate (OS X) or E Text...
- Writing C extensions in RubyGems using newgem generators (plus a free TextMate bundle) Already know C extensions in RubyGems? Cool – then just...
- Rails 2.0 TextMate bundle – Tasty Tidbit – respond_to and view navigation The new release of the Rails TextMate bundle is coming...