From 5221038f6e3a434d4e2062c7cdc68f09baa7e7c4 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Tue, 21 Apr 2015 14:47:17 +0800 Subject: [PATCH] Vim-rails --- vim-rails.md | 136 +++++++++++++++++++++++++++++++++++++++++++++++++++ vim.md | 1 + 2 files changed, 137 insertions(+) create mode 100644 vim-rails.md diff --git a/vim-rails.md b/vim-rails.md new file mode 100644 index 000000000..bead3fc22 --- /dev/null +++ b/vim-rails.md @@ -0,0 +1,136 @@ +--- +title: Vim-rails +html_class: key-codes +--- + +Alternate files +--------------- + +| `:A` | alternate file | +| `:R` | related file | + +### What it does + +| . | :A | :R | +| ---- | --- | --- | +| **Model** | test/models/ | db/schema.rb | +| **Controller method** | test/controllers/ | app/views/ | +| **View template** | test/views/ | app/controllers | + +Abbreviations +------------- + +Type `:Rabbrev` for a full list. + +| Abbrev | Expansion | +| --- | --- | +| `AC::` | ActionController | +| `AR::` | ActiveRecord | +| `AV::` | ActionView | +| `...` | ... | +| --- | --- | +| `logd(` | logger.debug | +| `logi(` | logger.info | +| `...` | ... | +{:.no-head.greycode} + +### Model + +| Abbrev | Expansion | +| --- | --- | +| `bt(` | `belongs_to` | +| `hm(` | `has_many` | +| `ho(` | `has_one` | +| `habtm(` | `has_and_belongs_to_many` | +{:.no-head.greycode} + +### Controllers + +| Abbrev | Expansion | +| --- | --- | +| `pa[` | params | +| `re(` | redirect_to | +| `rp(` | render partial: | +| `rst(` | respond_to | +{:.no-head.greycode} + +### Views + +| Abbrev | Expansion | +| --- | --- | +| `dotiw` | `distance_of_time_in_words` | +| `taiw` | `time_ago_in_words` | +{:.no-head.greycode} + +Extracting partials +------------------- + +```rb +# from view => app/views/home/_foo_partial.haml + :Rextract home/foo_partial + +# from model => app/models/concerns/foo_concern.rb + :Rextract FooConcern +``` + +Loading files +------------- + +### App + + :Econtroller # app/controllers/*_controller.rb + :Ehelper # app/helpers/*_helper.rb + :Emodel # app/models/*.rb + :Ejob # app/jobs/*_job.rb + :Emailer # app/mailers/*.rb + +### DB + + :Emigration # db/migrations/*.rb + :Eschema # db/schema.rb + +### Lib + + :Elib # lib/*.rb + :Elib # Gemfile + :Etask # lib/tasks/*.rake + +### Assets + + :Estylesheet + :Ejavascript + +### Views + + :Eview + :Elayout + +### Test + + :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 + +### Config + + :Einitializer # config/initializers/*.rb + :Elocale # config/locales/*.yml + :Eenvironment # application.rb + :Eenvironment development # config/environments/*.rb + +## Reference + + * [vim-rails](https://github.com/tpope/vim-rails) diff --git a/vim.md b/vim.md index 7d4965a88..78a7d630a 100644 --- a/vim.md +++ b/vim.md @@ -8,6 +8,7 @@ layout: default * [Vimscript](vimscript.html) * [Vim-unite](vim-unite.html) * [Vim-easyalign](vim-easyalign.html) + * [Vim-rails](vim-rails.html) Command line ------------