<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title>Gray Soft / Tags / Editors</title>
  <id>tag:graysoftinc.com,2014-03-20:/tags/Editors</id>
  <updated>2014-03-28T23:06:33Z</updated>
  <link rel="self" href="http://graysoftinc.com/tags/Editors/feed.xml"/>
  <link rel="alternate" href="http://graysoftinc.com/tags/Editors"/>
  <author>
    <name>James Edward Gray II</name>
  </author>
  <entry>
    <title>Ruby Idioms Bundle for TextMate</title>
    <link rel="alternate" href="http://graysoftinc.com/tools-of-the-trade/ruby-idioms-bundle-for-textmate"/>
    <id>tag:graysoftinc.com,2006-04-12:/posts/14</id>
    <updated>2014-03-28T23:06:33Z</updated>
    <summary>This article is the beginning of the effort that later became the official Ruby bundle for TextMate.</summary>
    <content type="html">&lt;p&gt;&lt;em&gt;[&lt;strong&gt;Update&lt;/strong&gt;:  An improved version of Ruby Idioms has been merged into the Ruby bundle in TextMate.  Everyone gets Ruby Idioms with TextMate now.]&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you are a TextMate user (a Mac OS X text editor), we have something in common and you might be interested in the rest of this post.  If not, skip it.&lt;/p&gt;

&lt;p&gt;I have made my &lt;a href="https://github.com/textmate/ruby.tmbundle"&gt;Ruby Idioms&lt;/a&gt; bundle available for anyone who would like to download it and try it out.  This bundle contains all the Ruby shortcuts I use to program everyday.  I've spent a lot of energy over the last six months refining them down to the keystroke, so hopefully there is a lot of value hidden in there.&lt;/p&gt;

&lt;p&gt;If you just want to get to the goods and start playing, click the above link and run.  However, if you want some insight into my thinking with these shortcuts, read on…&lt;/p&gt;

&lt;h4&gt;Tab Triggers&lt;/h4&gt;

&lt;p&gt;I'm a Unix guy, so I'm very comfortable with two or three letter triggers and that's what you are going to find here.    Sometimes I use a one or two caracter trigger (r, w, and rw just make sense for &lt;code&gt;attr_reader&lt;/code&gt;, &lt;code&gt;attr_writer&lt;/code&gt;, and &lt;code&gt;attr_accessor&lt;/code&gt;, for example), but three is the norm.&lt;/p&gt;

&lt;p&gt;I mention this because it is not the TextMate style and may be a turn off to some.&lt;/p&gt;

&lt;h4&gt;Iterators&lt;/h4&gt;

&lt;p&gt;&lt;strong&gt;All&lt;/strong&gt; the core and many standard iterators are included in this bundle.  I do mine differently from the normal TextMate style though, so I better mention that too.  I find myself skipping around the object when it is included in the block more often than not (and I know where the escape key is when I do need the object), so I just want an empty block that leaves the snippet when I enter it (in case I need new triggers).  That's my style.&lt;/p&gt;

&lt;h4&gt;Tests&lt;/h4&gt;

&lt;p&gt;I've included a compete set of test snippets in this bundle.  It duplicates some work in the Rails bundle, but my opinion is that those tests are misplaced there anyway.&lt;/p&gt;

&lt;h4&gt;Automatic Requires&lt;/h4&gt;

&lt;p&gt;Some of my macros are really just snippets that ensure you have the proper require statement for the code.  This can cause TextMate to flash the syntax highlighting because I have to replace all the code up to the cursor.  If you would like to use the snippet, without the magic requires, just add a &lt;code&gt;-&lt;/code&gt; to the end of the tab trigger.&lt;/p&gt;

&lt;p&gt;I use magic requires only where they make sense.  For example, &lt;code&gt;def_delegator&lt;/code&gt; doesn't need one, because it's &lt;code&gt;extend Forwardable&lt;/code&gt;'s job to handle that.&lt;/p&gt;

&lt;h4&gt;Idioms&lt;/h4&gt;

&lt;p&gt;You will find some imaginary methods as snippet names, like &lt;code&gt;map_with_index&lt;/code&gt; and &lt;code&gt;flatten_once&lt;/code&gt;.  I use them because they are easy to remember names for more complicated idioms.  I feel this is more natural, but some may be surprised when the inserted code doesn't look like the snippet title.  Don't lose too much sleep over it, I say.&lt;/p&gt;

&lt;h4&gt;That Personal Touch&lt;/h4&gt;

&lt;p&gt;I wasn't kidding when I said these shortcuts are tuned to the keystroke.  I've refined them after a lot of actual usage for what works best for me.  You'll notice that extra tab stop in &lt;code&gt;unix_filter&lt;/code&gt; I leave in just to activate paragraph mode when I need it and that deleting &lt;code&gt;OTHER_ARGS&lt;/code&gt; in the option parsing code also removes the extra space.  There are larger scale preferences too, of course.  &lt;code&gt;assert&lt;/code&gt; needs a failure message, because it could be anything, but &lt;code&gt;assert_equal&lt;/code&gt; does not because the failure message makes sense from the method itself.&lt;/p&gt;

&lt;p&gt;If you think like I do or can at least get into the flow, this should become pretty comfortable to work with.  If not, it may just become a hellish set of magic rules you can't understand or remember.  If the lattar is true, you may have to resort to you own bundle of tricks, but perhaps this will at least give you some ideas.&lt;/p&gt;</content>
    <author>
      <name>James Edward Gray II</name>
    </author>
  </entry>
</feed>
