Ruby Snipmate Shortcuts (.rb files)

The Snipmate plugin has an extensive list of shortcuts for Ruby.  I looked through the list of shortcuts and have summarized a list that can be used on a regular basis.  Just type the keyword followed by a tab in a .rb file with the Snipmate plugin installed and the text will expand.  Make sure to tab through every step of the snippet so the cursor automatically jumps to convenient spots and so you get the full benefit of the plugin.

: expands to :key => “value”

def expands to a method definition block

beg expands to a begin rescue block

req – require line

cla – opens a menu at the bottom of the page and lets you select a class expansion snippet

r – attr_reader

w – attr_writer

rw – attr_accessor

ea – single line each block

ead – each block with do

eawi – single line each with index

eawid – each with index do block

map – single line map

mapd – map do block

ase – assert equal

asn – assert nil

asm – assert match

asr – assert raise

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s