Nov 12

TextMate Rails Cheat Sheet

Posted by Cliff

This is actually a duplication of this, but when I already have a million tabs open during the course of development, I’d rather not open another with a big fat Flash applet in it. So I created myself the following text only version. The characters I’ve used aren’t perfect, I’ll fix them when I get a chance..

Legend:

Apple / Command
Shift
Option
Control
Tab
Enter

File navigation

Go to file ⌘T
Go to line ⌘L
Go to method ⇑⌘T
Go to file ⇑⌘F
Go to file ∧⌘R

Editing

Code completion Escape
Fold / Unfold F1
Comment selection ⌘/
Indent / Unindent selection ⌘[ and ⌘]
Move selection ∧⌘(arrow)
Edit selection ⌥⌘A
Column selection ⌥(drag)
Insert tag ∧⇑<
Wrap selection in tag ∧⇑W
Close tag ⌥⌘.
Wrap selection as link ∧⇑L
Subversion menu ∧⇑A
New method name∧↵

Commands (⇑⌥⌘C)

Run file as Ruby ⌘R
Start IRB ∧⇑I

Snippets (⇑⌥⌘S)

class class_name class➾
def method_name def➾
each { |method_name| } each➾
for element in collection forin➾
if condition if➾ or elsif➾
unless condition unless➾
:key => :value :➾
flash[:notice] = "…" flash➾
logger.info "…" logi➾
assert_equal value, @o.attr ac➾
redirect_to options rec[ai]➾
render :action => "action" ra➾
render :partial => "item" rp[loc]➾
create_table "table" mct➾
table.column :,: mcc➾
<%= link_to options lic[ai]➾
<% for item in @items eforin➾
<%= form_tag options ft➾
has_many :objects hm➾
belongs_to :object bt➾
validates_presence_of :attr vpif➾
=> ∧L
params[:id] ∧P
session[:user] ∧J
<% %> ∧X
<%= %> ∧Z