Is there currently a plugin that you ruby on rails developers that are also using macvim/gvim/vi开发者_C百科m that allows you to take a quick block of code and create a partial from it? I know that TextMate does this, figured someone has ported it by now to vim also.
You want Tim Pope's rails.vim plugin:
http://rails.vim.tpope.net/
It provides an :Rextract
command that pulls a range of lines into a partial. Here's a very short demo of it in action:
http://rails.vim.tpope.net/images/rpartial.gif
(The :Rpartial
command in the demo is an alias for :Rextract
.)
The plugin provides dozens of other features, too, and many people consider it a must-have for Rails development in Vim.
It works in vim with vim-rails plugin.
- Select in visual mode code which you need to send to partial
- Press key
:
and you will see:'<,'>
- Complete command to
:'<,'>Rextract partial_name
where partial_name will your partial's file name. You can set folder for partial, for example:'<,'>Rextract shared/menu
- Press
Enter
and enjoy.
rails.vim can do this. From the features summary:
:Rextract
file replaces the desired range (ideally selected in visual line mode) withrender :partial => 'file'
, which is automatically created with your content. The@file
instance variable is replaced with the file local variable.
精彩评论