fregas
fregas

Reputation: 3260

Ruby refactoring in Vim

I'm a big fan of Resharper in Visual Studio. It has some awesome refactoring tools, similar to what you get in Eclipse for Java. Is there anything like this for Ruby? Better yet, is there a plugin or something into Vim that does refactoring for Ruby code like renaming all instances of a method or variable, renaming classes sitewide, etc?

Upvotes: 9

Views: 2174

Answers (4)

sparrovv
sparrovv

Reputation: 7824

You can check out Vim Ruby Refactoring. It has several useful refactoring patterns.

Upvotes: 10

OscarRyz
OscarRyz

Reputation: 199333

The problem with some refactorings in Ruby and other dynamic typed languages, is the lack of information of the type being refactored.

From Cedric Beust blog entry:

A few months ago, I offered the following code snippet to the author of the Ruby Refactoring Browser:

def f1(o)
    o.init
end

def f2(o)
    o.init
end

class C
   def init
      ...
   end
end

And I asked him: "If I rename C.init to C.init2, how do you know which o.init must be renamed in f1 and f2?".

His response was unequivocal:

"This problem is difficult for dynamically typed language. I think computer can't determine whether those must be renamed or not."

"Therefore Ruby Refactoring Browser provides two functions, one is renaming all methods that have same name, and another is renaming only methods and calls that cleary belong the class. The former renames o.init in f1 and f2, and the latter doesn't rename them."

Read the whole entry here: Dynamic language, refactoring IDE. Pick one.

Having said that, Jetbrains has the Ruby Mine IDE which has a good number of refactorings. I'm not sure how they manage this scenario though.

Ruby Mine refactorings http://img709.imageshack.us/img709/917/refactoringsonrubymine.png

There is nothing similar for VIM that I'm aware.

Upvotes: 5

Jake Kalstad
Jake Kalstad

Reputation: 2065

Jetbrains puts out an IDE RubyMine that does have some basic functionality of refactorings, no where near the power of resharper(surprising as its the same company putting out both prodcuts). I tend to only use rubymine after stumbling upon it a few months back.

Upvotes: 0

whazzmaster
whazzmaster

Reputation: 576

I also love Resharper for C# development-- I know Jetbrains released a Ruby IDE called RubyMine that includes refactoring tools, etc. I've been meaning to try it out but I prefer Textmate on my Mac. Not sure about VIM tools, though.

Upvotes: 0

Related Questions