Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Vim-rails
  • Loading branch information
rstacruz committed Apr 21, 2015
1 parent d9fdad2 commit 5221038
Show file tree
Hide file tree
Showing 2 changed files with 137 additions and 0 deletions.
136 changes: 136 additions & 0 deletions 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 <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

### 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 <file> # config/initializers/*.rb
:Elocale # config/locales/*.yml
:Eenvironment # application.rb
:Eenvironment development # config/environments/*.rb

## Reference

* [vim-rails](https://github.com/tpope/vim-rails)
1 change: 1 addition & 0 deletions vim.md
Expand Up @@ -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
------------
Expand Down

0 comments on commit 5221038

Please sign in to comment.