views:

50

answers:

2

Is there currently a plugin that you ruby on rails developers that are also using macvim/gvim/vim 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.

+1  A: 

rails.vim can do this. From the features summary:

:Rextract file replaces the desired range (ideally selected in visual line mode) with render :partial => 'file', which is automatically created with your content. The @file instance variable is replaced with the file local variable.

mikej
+3  A: 

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.

Bill Odom