Cheatography
https://cheatography.com
vim short cuts for Rails development
This is a draft cheat sheet. It is a work in progress and is not finished yet.
File Type Navigation Commands
:Econtroller |
:Scontroller |
:Scontroller events |
:Scontroller events/registrations |
:Scontroller eve↹ |
:Scontroller regi↹ |
:Scontroller events#index |
:Scontroller events#show |
:Scontroller events:15 |
:Scontroller events/upcoming! |
:Scontroller events! |
:Scontroller events/registrations! |
|
:Senvironment |
:Senvironment development |
:Senvironment pro↹ |
:Senvironment test |
|
:Sfixtures |
|
:Sfunctionaltest |
|
:Shelper |
|
:Sinitializer |
:Sinitializer inflections |
|
:Sinitializer lograge! |
|
:Sintegrationtest |
|
:Sjavascript |
|
:Slayout |
|
:Slib |
|
:Sspec |
|
:Slocale |
|
:Smailer |
|
:Smigration |
Smigration regi↹ |
|
:Smodel |
:Smodel <C-a> <C-a> |
:Smodel event! |
|
:Smigration |
|
:Smodel |
|
:Sschema |
|
:Sstylesheet |
|
:Stask |
|
:Sunittest |
|
:Sview index.html.erb |
:Sview index.htm.erb! |
:Sview events/upcoming/index.html.erb |
:Sview layouts/_footer.html.erb! |
Each of the following commands has variants for splitting, vertical splitting, opening in a new tab, and reading the file into the current buffer. For :Emodel, those variants would be :Smodel, :Vmodel, :Tmodel, and :Dmodel.
|
|
gf or C-w f (* indicates cursor position)
Pos*t.first app/models/post.rb |
has_many :c*omments app/models/comment.rb |
link_to 'Home', :controller => 'bl*og' app/controllers/blog_controller.rb |
<%= render 'sh*ared/sidebar' %> app/views/shared/_sidebar.html.erb |
<%= stylesheet_link_tag 'appl*ication' %> app/assets/stylesheets/application.css |
class BlogController < Applica*tionController app/controllers/application_controller.rb |
class ApplicationController < ActionCont*roller::Base .../action_controller/base.rb |
fixtures :pos*ts test/fixtures/posts.yml |
layout :pri*nt app/views/layouts/print.html.erb |
<%= link_to "New", new_comme*nt_path %> app/controllers/comments_controller.rb (jumps to def new) |
In the last example, the controller and action for the named route are determined by evaluating routes.rb as Ruby and doing some introspection. This means code from the application is executed. Keep this in mind when navigating unfamiliar applications.
Snippet Rails
routes.rb |
r |
|
XXXXX_controller.rb |
ci || cindex |
def index |
cni || cnindex |
def index (nested) |
cs || cshow |
def show |
cns || cnshow |
def show (nested) |
cn || cnew |
def new |
cnn || cnnew |
def new (nested) |
cc || ccreated |
def create |
cnc || cncreate |
def create (nested) |
ce || cedit |
def edit |
cne || cnedit |
def edit (nested) |
cu || cupdate |
def update |
cnu || cnupdate |
def update (nested) |
cd || cdestroy |
def destroy |
cnd || cndestroy |
def destroy (nested) |
|