Execute ruby code inline in the editor


I’ve often wondered how in Ruby screencasts they magically execute code inline in the editor, e.g. they type:

[1, 2, 3].reverse # =>

…and it magically becomes

[1, 2, 3].reverse # => [3, 2, 1]

You can see how effective this is in action in one of the sample episodes for Ruby Tapas by the wise and excellent Avdi Grimm.

Today I learned how. Apparently it’s a Textmate feature called “Execute and Update ‘# =>’ Markers” which has been ported over to other editors:

This also explains why the Sublime Text snippet for # expands to # =>. I’d always assumed that this was intended to make multiline comments more readable. That sounds a bit silly now that I know :)