vim-rails är ett omfattande Vim-plugin för Ruby on Rails-utveckling skapat av Tim Pope.
Navigering i Rails-projekt
Alternativa & Relaterade filer
| Kommando | Beskrivning |
|---|---|
:A |
Hoppa till alternativ fil (t.ex. test / spec) |
:R |
Hoppa till relaterad fil (t.ex. controller / view / schema) |
| Kontext | :A Mål | :R Mål |
|---|---|---|
| Modell | test/models/ or spec/models/ |
db/schema.rb |
| Controller | test/controllers/ or spec/controllers/ |
app/views/<controller>/ |
| Vymall | test/views/ or spec/views/ |
app/controllers/<controller>_controller.rb |
Extrahera partials och concerns
" Från en ERB/Haml-vy till en partial => app/views/home/_foo_partial.html.erb
:Rextract home/foo_partial
" Från en modell till en concern => app/models/concerns/foo_concern.rb
:Rextract FooConcern
Öppna Rails-filer
Applikationskod
: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
Databas & Migreringar
:Emigration <name> # db/migrate/*.rb
:Eschema # db/schema.rb
Bibliotek & Rake-uppgifter
:Elib <name> # lib/*.rb
:Elib # Gemfile
:Etask <name> # lib/tasks/*.rake
Vyer & Layouter
:Eview <name> # app/views/...
:Elayout <name> # app/views/layouts/...
Tester & Specifikationer
: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
Konfiguration
:Einitializer <name> # config/initializers/*.rb
:Elocale <name> # config/locales/*.yml
:Eenvironment # config/application.rb
:Eenvironment development # config/environments/development.rb
Inbyggda förkortningar (abbreviations)
Kör :Rabbrev i Vim för att inspektera hela listan.
Modeller (Models)
| Förkortning | Expansion |
|---|---|
bt( |
belongs_to |
hm( |
has_many |
ho( |
has_one |
habtm( |
has_and_belongs_to_many |
Controllers
| Förkortning | Expansion |
|---|---|
pa[ |
params |
re( |
redirect_to |
rp( |
render partial: |
rst( |
respond_to |