Riferimento rapido

Cheat Sheet Vim-Rails

Guida rapida al plugin tpope/vim-rails: navigazione tra file alternativi e correlati, estrazione di partial, abbreviazioni e comandi di salto.

· Pubblicato

vim-rails è un plugin completo per Vim dedicato allo sviluppo Ruby on Rails creato da Tim Pope.

Navigazione nel progetto Rails

File alternativi e correlati

Comando Descrizione
:A Salta al file alternativo (es. test / spec)
:R Salta al file correlato (es. controller / view / schema)
Contesto Destinazione di :A Destinazione di :R
Modello (Model) test/models/ or spec/models/ db/schema.rb
Controller test/controllers/ or spec/controllers/ app/views/<controller>/
Template vista (View Template) test/views/ or spec/views/ app/controllers/<controller>_controller.rb

Estrazione di partial e concern

" Da una vista ERB/Haml a un partial => app/views/home/_foo_partial.html.erb
:Rextract home/foo_partial

" Da un modello a un concern => app/models/concerns/foo_concern.rb
:Rextract FooConcern

Apertura rapida dei file Rails

Codice applicativo

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

Database e migrazioni

:Emigration <name>      # db/migrate/*.rb
:Eschema                # db/schema.rb

Librerie e task Rake

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

Viste e layout

:Eview <name>           # app/views/...
:Elayout <name>         # app/views/layouts/...

Test e specifiche

:Espec <name>           # spec/.../*_spec.rb
:Eunittest <name>       # test/models/..._test.rb
:Efunctionaltest <name> # test/controllers/..._test.rb
:Eintegrationtest <name># test/integration/..._test.rb
:Efixtures <name>       # test/fixtures/*.yml

Configurazione

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

Abbreviazioni integrate

Esegui :Rabbrev in Vim per visualizzare l'elenco completo.

Modelli (Models)

Abbreviazione Espansione
bt( belongs_to
hm( has_many
ho( has_one
habtm( has_and_belongs_to_many

Controller

Abbreviazione Espansione
pa[ params
re( redirect_to
rp( render partial:
rst( respond_to

Riferimenti

Argomenti correlati