Cheat Sheet速查表
跳转到主要内容

Vim-rails 速查表

本文根据 Devhints / Vim-rails 翻译。代码示例及版本范围沿用原文。

关联文件

关联文件

命令说明
:A关联文件(测试)
:R相关文件(控制器/视图)

其功能

.:A:R
模型test/models/db/schema.rb
控制器方法test/controllers/app/views/
视图模板test/views/app/controllers

缩写

类型 (Type) :Rabbrev 查看完整列表。

缩写展开
AC::ActionController
AR::ActiveRecord
AV::ActionView
...…
logd(logger.debug
logi(logger.info
...…

模型

缩写展开
bt(belongs_to
hm(has_many
ho(has_one
habtm(has_and_belongs_to_many

控制器

缩写展开
pa[params
re(redirect_to
rp(render partial:
rst(respond_to

视图 (Views)

缩写展开
dotiwdistance_of_time_in_words
taiwtime_ago_in_words

提取局部视图 (partials)

# from view => app/views/home/_foo_partial.haml
  :Rextract home/foo_partial

# from model => app/models/concerns/foo_concern.rb
  :Rextract FooConcern

加载文件

App

:Econtroller <file>     # app/controllers/*_controller.rb
:Ehelper                # app/helpers/*_helper.rb
:Emodel <file>          # app/models/*.rb
:Ejob <file>            # app/jobs/*_job.rb
:Emailer <file>         # app/mailers/*.rb

DB

:Emigration <file>     # db/migrations/*.rb
:Eschema               # db/schema.rb

Lib

:Elib <file>      # lib/*.rb
:Elib             # Gemfile
:Etask <file>     # lib/tasks/*.rake

Assets

:Estylesheet
:Ejavascript

视图 (Views)

:Eview
:Elayout

测试

:Espec
:Eunittest
  # test/{unit,models,helpers}/*_test.rb
  # spec/{unit,models,helpers}/*_spec.rb

:Efunctionaltest
  # test/{functional,controllers,mailers}/*_test.rb
  # spec/{functional,controllers,mailers}/*_spec.rb

:Eintegrationtest
  # test/integration/*_test.rb
  # spec/{features,requests,integration}/*_spec.rb
  # features/*.feature

:Efixtures
:Efunctionaltest

配置

:Einitializer <file>          # config/initializers/*.rb
:Elocale                      # config/locales/*.yml
:Eenvironment                 # application.rb
:Eenvironment development     # config/environments/*.rb

参考资料