vim-rails est un plugin Vim complet pour le développement Ruby on Rails conçu par Tim Pope.
Navigation dans les projets Rails
Fichiers alternatifs et associés
| Commande | Description |
|---|---|
:A |
Sauter au fichier alternatif (ex. test / spec) |
:R |
Sauter au fichier associé (ex. contrôleur / vue / schéma) |
| Contexte | Cible de :A | Cible de :R |
|---|---|---|
| Modèle (Model) | test/models/ or spec/models/ |
db/schema.rb |
| Contrôleur (Controller) | test/controllers/ or spec/controllers/ |
app/views/<controller>/ |
| Modèle de vue (View Template) | test/views/ or spec/views/ |
app/controllers/<controller>_controller.rb |
Extraire des partiels et des concerns
" Depuis une vue ERB/Haml vers un partial => app/views/home/_foo_partial.html.erb
:Rextract home/foo_partial
" Depuis un modèle vers un concern => app/models/concerns/foo_concern.rb
:Rextract FooConcern
Ouvrir les fichiers Rails
Code applicatif
: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
Base de données & Migrations
:Emigration <name> # db/migrate/*.rb
:Eschema # db/schema.rb
Bibliothèques & Tâches Rake
:Elib <name> # lib/*.rb
:Elib # Gemfile
:Etask <name> # lib/tasks/*.rake
Vues & Mises en page
:Eview <name> # app/views/...
:Elayout <name> # app/views/layouts/...
Tests & Spécifications
: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
Configuration
:Einitializer <name> # config/initializers/*.rb
:Elocale <name> # config/locales/*.yml
:Eenvironment # config/application.rb
:Eenvironment development # config/environments/development.rb
Abréviations intégrées
Exécutez :Rabbrev dans Vim pour consulter la liste complète.
Modèles (Models)
| Abréviation | Expansion |
|---|---|
bt( |
belongs_to |
hm( |
has_many |
ho( |
has_one |
habtm( |
has_and_belongs_to_many |
Contrôleurs (Controllers)
| Abréviation | Expansion |
|---|---|
pa[ |
params |
re( |
redirect_to |
rp( |
render partial: |
rst( |
respond_to |