Sublime Text Cheat Sheet for Ruby & Ruby on Rails


Install the following plugins:

Rails ERB Tags

Snippet Tab Trigger Output
ERB tags er <% %>
print ERB tags pe <%= %>
print ERB comment pc <%# %>
if block if <% if %>...<% end %>
if / else block ife <% if %>...<% else %>...<% end %>
else tag else <% else %>
elsif tag elsif <% elsif %>
end block end <% end %>
link_to helper lt <%= link_to ..., ... %>
form_for helper form ` <%= form_for(@) do
t() helper t <%= t('@') %>

File Navigation

Action Shortcut Keys
Open Related Rails Model super+1
Open Related Rails Controller super+2
Open Related Rails View super+3
Open Related Rspec Model super+4
Open Related Rspec Controller super+5

Find in Files

Action Shortcut Keys
Find Files ctrl + p
Find next next F3
Find previous previous shift F3
Search all files in a folder ctrl+shift+f
Replace ctrl+h
Find a certain term and then select them all for mutli-editing ctrl+f then alt+enter

Quick File Commands

Action Shortcut Keys
Show / Hide minibar ctrl + kb
Close Files ctrl + w
For creating closing panels shift + alt + 1 or 2 or3
Indent or Un-Indent ctrl + [ or ]
Highlight Line ctrl + H
Delete Line ctrl + KK
Goto Line ctrl + W
Select the next instance of the currently highlighted text ctrl + D
Move blocks of code up/down ctlr + shift + up or down arrow
Toggle commenting a block ctrl + /
Duplicate a selection ctrl + shift + D


Action Shortcut Keys
logger - debug logd
logger - info logi
logger - warn logw
logger - error loge
logger - fatal logf
redirect_to (action) rea
redirect_to (controller) rec
redirect_to (nested path) renp
redirect_to (path) rep
render (action) ra
render (action, layout) ral
render (inline) ri
render (layout) rl
render (partial) rp
render (update) ru


Action Shortcut Keys
All Commands ctrl + shift + p git
Git Add ctrl + shift + p gadd
Git Status ctrl + shift + p gstat
Git Commit ctrl + shift + p gcom
Git log ctrl + shift + p glog
Git diff ctrl + shift + p gdiff
Git push ctrl + shift + p gpush
Git pull ctrl + shift + p gpull


Action Shortcut Keys
Run single ruby test Command-Shift-R
Run all ruby tests from current file Command-Shift-T
Run last ruby test(s) Command-Shift-E
Show test panel Command-Shift-X (when test panel visible hit esc to hide it)
Check RB, ERB file syntax Alt-Shift-V
Switching between code and test (create a file if not found) Single View Command-.
Switching between code and test (create a file if not found) Split View Command-Ctrl-.


Action Shortcut Keys
Beautify Ruby Code ctrl + alt + K
Create Partial alt + p
Create Partial and open Shift + alt + p
Extract Method Alt+M
Paste extracted method (with indent) Shift+Ctrl+V


Action Shortcut Keys
Bundle Install ctrl+alt+b
Capistrano Tasks ctrl+alt+c
Rails Generators ctrl+alt+g
Rake Tasks ctrl+alt+r


Action Shortcut Keys
Run a Cake task alt+shift+t
Run some CoffeeScript (prints output to a panel on the bottom) alt+shift+r
Run a syntax check alt+shift+s
Compile a file alt+shift+c
Display compiled JavaScript alt+shift+d
Display lexer tokens alt+shift+l
Display parser nodes alt+shift+n
Toggle watch mode alt+shift+w
Toggle output panel alt+shift+p

GUI Based commands

Action Shortcut Keys
List all : Models, controllers,views, fixures, helpers, stylesheets etc ctrl + shift + p list
Guard : Start, stop, toggle log output, run tests ctrl + shift + p guard
Set Syntax ctrl + shift + p syn
Generate : Controller, migration, model ctrl + shift + p generate


Action Shortcut Keys
Easy file creation Command-Shift-C
Open In Browser Ctrl + alt + v
Color Picker ctrl+shift+c

Rails Form Helpers

Tab Trigger Form Component Output Code Snippet
ffs f.submit <%= f.submit "Submit", :disable_with => 'Submiting...' %>
ffpf f.password_field <%= f.password_field :attribute %>
ffta f.text_area <%= f.text_area :attribute %>
ffcb f.check_box <%= f.check_box :attribute %>
ffl f.label <%= f.label :attribute, "Attribute" %>
ffrb f.radio_box <%= f.radio_box :attribute, :tag_value %>
fftf f.text_field <%= f.text_field :attribute %>
ffff f.file_field <%= f.file_field :attribute %>
ffhf f.hidden_field <%= f.hidden_field :attribute %>
ff form_for `<% form_for @model do
ffcb form_for check_box <%= f.check_box :attribute %>
ffe form_for with errors `<%= f.check_box :attribute %> <%= error_messages_for :model %> <% form_for @model do
ft form_tag <% form_tag(:action => "update", {:class => "form"}) do %> <% end %>
lia link_to (action) <%= link_to "link text...", :action => "index" %>
liai link_to (action, id) <%= link_to "link text...", :action => "edit", :id => @item %>
lic link_to (controller) <%= link_to "link text...", :controller => "items" %>
lica link_to (controller, action) <%= link_to "link text...", :controller => "items", :action => "index" %>
licai link_to (controller, action, id) <%= link_to "link text...", :controller => "items", :action => "edit", :id => @item %>
lim link_to model <%= link_to, model_path(model) %>
linp link_to (nested path) <%= link_to "link text...", parent_child_path(@parent, @child) %>
linpp link_to (nested path plural) <%= link_to "link text...", parent_child_path(@parent) %>
lip link_to (path) <%= link_to "link text...", model_path(@model) %>
lipp link_to (path plural) <%= link_to "link text...", models_path %>

You may also be interested in


Talk to us, that's always a good idea!