TextMate Tip #1 (Hashes)

I get disappointed when people don’t make an effort to learn their tool set.  I am guilty of this as I used to be a hard core emacs user, but when I moved from GNU\Linux to Mac OSX, I migrated to Textmate and stopped programming full time.  I never took the time to learn the new editor.  Having paired a lot lately with our interns I feel I am doing them a dis-service by not giving them a full arsenal of tricks in their primary weapon “the editor”.  Mountain West Ruby Conference inspired me to do something about it, well actually the RV Trip there and back.

So, I am going to try and do a Textmate Tip/Trick of the week (or maybe day).  Many of these items will be new to me as well, so if I mess it up or miss something cool, please let me know.  If you find them valuable also let me know.  Here is the first installation.

Text Mate Tip of the Day (Hashes) Episode 1 from Derek Neighbors on Vimeo.


  1. This sounds like it will be a great teaching tool. The first video was short and instructive. I use vim, but this video was useful because it reminded me that I need to figure out how snippets work in vim, and gave me the idea to add a shortcut for the hash rocket string.

  2. Patrick,

    I plan to do all the tips as screencasts. The goal is to keep them under 2 minutes. Bite size. I also plan on doing BASH (shell) tips of the day as well. As always I have even a bigger master plan than that, but figured we would start here.


  3. Great quick tutorial. I’ve been using TextMate for long time now but I haven’t taken the time to learn all the magic it can do. Keep it coming!

    Here is a shortcut that saves me a lot time:

    This outputs a copyright notice, which I have customized to my needs.

  4. I’m really thrown by your last Hash example. What exactly is:

    Hash.new {|format.xml, xml| format.xml[xml] = @post}


    From what I understand, Hash.new {|hash, key| …} allows you to create a Hash with a custom default value. But then having format.xml as a block parameter results in format.xml getting set to the hash you created..? It seems to be equivalent to:

    h = Hash.new do |hash, key|
    format.xml = h
    format.xml[key] = @post

    Is that right? What does that end up doing exactly?

  5. I learned the Control-L shortcut to type a hashrocket (=>), then switched back to the manual way when I found myself trying (and failing) to type Control-L in the Console. Choose your habituations wisely.

  6. My main argument is why are you programming from the console? It should be in frequent enough that your editor habits shouldn’t be too cumbersome. Though I admit when I am in console I swear a lot more. 🙂

  7. Jordan, I definitely am not a Ruby master and Im doing the tips in about 10 minutes or less with no planning. So, definitely there is a good chance the ruby syntax will be wrong. FWIW i think your assessment of the code is correct.

  8. […] Dica número 1 (Hashes) – o Derek demonstra como o Textmate pode facilitar sua vida quando estiver manipulando hashes do Ruby, incluindo atalho para produzir hashrockets (=>), atalho para pares chave/valor, criar um novo hash, etc. […]

  9. These look really good. I started down the same track a while ago but ended but being to busy doing other things as usual. I managed 4 video’s which can be found here.

    Hope you can keep it going for longer than I did!


Comments are closed.