Cross-Platform Rails Editor

I do own a Macbook, I’ll get that out up front.  I understand that the standard image of a rails developer is a person sitting behind a Macbook using Textmate as their editor.  I really wanted to be that person, I tried really hard to do that.  The biggest stumbling block I have is that my job allows me a nearly unlimited amount of PC hardware to play with and very little to no Apple hardware.

I have nothing against Apple or Macs in general.  I’ve owned several Macs through the years and while they’re nice and look great, there’s always some little thing that frustrates me and I walk away.  The last was trying to keep the Macbook running with the lid down.  Apple says that when you close the lid, you’re done.  That’s great but what if I’m not?

I am clearly not the target audience for the Mac and while it does just work, it also does so with a price.  You can’t do things your way.  Like I said, this is great for some people and I’m not knocking that at all.  To some, the price you pay to just be able to use a computer and have it handle everything for you is totally worth it.  For me, I’m a tweaking, gear turning, tech that likes to bend technology to my will.  So while I did find a nice utility to keep the Macbook running when you close the lid, it was just the straw that broke the camel’s back.

So with two PC laptops and various Dells at my disposal I set out to build an environment that I could use to develop in rails 3.  My previous post talked about setting up that environment but once it’s setup you will need an editor to do your work in.  That editor, after much looking, is Sublime Text 2.

Sublime Text 2 is cross-platform and will run on Mac OS X, Linux and Windows.  On top of this the editor is very customizable.  You can tweak it to be the editor you need.  This is great because at first I didn’t think it would work for me as it didn’t auto-pair rails tags in my views.  It’s such a simple thing but I really like that when I type <% I get the ending tag and I want my cursor to be placed next to the open tag.

After much digging and trial and error I was able to put together a fairly simple keymap for myself that might help others in their pursuit of the perfectly tweaked editor.  This is my user keymap:

[
{ "keys": ["alt+/"], “command”: “move_to”, “args”: {“to”: “eol”, “extend”: false} },
{ “keys”: ["alt+,"], “command”: “move”, “args”: {“by”: “characters”, “forward”: true} },
{ “keys”: ["alt+."], “command”: “move”, “args”: {“by”: “wordends”, “forward”: true} },
// Auto-pair Rails erb tags
{ “keys”: ["<", "%"], “command”: “insert_snippet”, “args”: { “contents”: “<%$0 %>” } }
]

Note: For Mac OS X use super instead of alt.

It’s simple and the auto-pairing is done for me, not as nicely as brackets or quotes but it works for me.  The alt key commands are what I came up with to allow me to easily move around my code without the need to remove my hands from the keyboard.  The one I use most is ALT+. as it allows me to just quickly move to the ends of words when typing commands such as link_to.

It’s a great editor and actually supports textmate snippets and has so much power under the hood that I’ve barely even touched.  It’s priced the same as Textmate and it’s definitely worth it.  You get cross-platform use, textmate snippets, the power to tweak the editor to your liking and so much more.