简体   繁体   中英

Remapping Econtroller in Rails.vim

I started using Vim to do my editing in Ruby on Rails, so I installed the Rails.vim plugin. I really like this plugin, but I have a few issues with it:

  1. I have to type :Econtroller Controller to edit a controller. The same for models (:Emodel Model), etc. If I had a controller named people, it would be much easier to type :ec People and press enter. This would save me 9 characters , not counting every time I have to hit the shift key to capitalize the E!
  2. I don't feel that I should have to capitalize the class name when opening the file as described in bullet #1. For example, if I do want to edit the People controller, I have to press the shift key before I even start to type the name of the class. Then, I type fast enough that I regularly hold down shift too long and People becomes PEople , then Rails.vim RENAMES the file to PEople!

If you have any solutions or suggestions, please let me know. Thank you for your help!

You can use :cabbrev to make exactly the shortcut you're asking for:

:cabbrev ec Econtroller

This way, when typing ec<space> , this will expand to Econtroller<space> anywhere on the command line. See :help abbreviations for more details.

As for capitalization, I don't actually think you need to capitalize the controller. At least on my installation of rails.vim, :Econtroller users works just fine to get me to the UsersController . Maybe you should update your rails.vim plugin?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM