مرجع سريع

ورقة مساعدة لإضافة Vim-Rails

مرجع سريع لإضافة tpope/vim-rails: التنقل بين الملفات البديلة وذات الصلة، واستخراج الجزئيات، والاختصارات وأوامر القفز.

· تاريخ النشر

vim-rails هي إضافة Vim شاملة لتطوير تطبيقات Ruby on Rails من تطوير Tim Pope.

التنقل في مشروع Rails

الملفات البديلة وذات الصلة

الأمر الوصف
:A الانتقال إلى الملف البديل (مثل الاختبارات / spec)
:R الانتقال إلى الملف ذي الصلة (المتحكم / العرض / المخطط)
السياق هدف :A هدف :R
النموذج (Model) test/models/ or spec/models/ db/schema.rb
المتحكم (Controller) test/controllers/ or spec/controllers/ app/views/<controller>/
قالب العرض (View Template) test/views/ or spec/views/ app/controllers/<controller>_controller.rb

استخراج القوالب الجزئية والاهتمامات المشتركة

" من ملف عرض ERB/Haml إلى ملف جزئي => app/views/home/_foo_partial.html.erb
:Rextract home/foo_partial

" من ملف نموذج إلى concern مشترك => app/models/concerns/foo_concern.rb
:Rextract FooConcern

فتح ملفات مشروع Rails بسرعة

أكواد التطبيق

: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

قاعدة البيانات والترحيلات

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

المكتبات والمهام (Tasks)

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

طرق العرض والتخطيطات

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

ملفات الاختبارات والـ Specs

: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

ملفات الإعدادات والتهيئة

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

الاختصارات البرمجية المدمجة

قم بتشغيل :Rabbrev داخل Vim لعرض القائمة النشطة بالكامل.

اختصارات النماذج (Models)

الاختصار التوسع
bt( belongs_to
hm( has_many
ho( has_one
habtm( has_and_belongs_to_many

اختصارات المتحكمات (Controllers)

الاختصار التوسع
pa[ params
re( redirect_to
rp( render partial:
rst( respond_to

المراجع والتوثيق

موضوعات ذات صلة