I use vim as my editor but I would like to get some of the same power of the IDE's for java when it comes to refactoring. Are there any commandline tools for refactoring java? I could probably hack something together using perl or vim scripting but if there is something already out there I'd rather use that.

- 30,470
- 17
- 104
- 128

- 23,907
- 5
- 55
- 73
-
1What are you trying to achieve? – Peter Apr 01 '09 at 04:49
-
3mostly just renaming classes, methods and variables across files. That's my most common use case. – Jeremy Wall Apr 01 '09 at 13:31
-
are there any not open source command line tools? Any tools would be nice. – jedierikb Jan 06 '13 at 18:32
-
Not open source, but may do some of what you want: http://stackoverflow.com/questions/28119760/automatic-code-simplification-via-refactoring – Ira Baxter Feb 04 '15 at 06:37
5 Answers
You could try Eclim. The goal of Eclim is to expose the functionality of Eclipse within Vim. In particular, there are a few commands for refactoring that are supported.

- 38,421
- 18
- 121
- 193
Check out jrefactory, and its command line option.

- 39,541
- 12
- 93
- 133
-
2Yeah, not that sophisticated. I use IntelliJ and Netbeans, though. – Adeel Ansari Apr 01 '09 at 06:11
Code refactoring is a very context-sensitive and interaction-heavy process which doesn't lend itself very well to command-line interfaces. There can be dozens of types of refactorings you could do to a particular file (or set of files) and coming up with a vim interface to integrate all of this would be a major challenge.
If you want IDE functionality, why not use an IDE? Especially with Java, which lends itself so well to automatic refactoring by a complex piece of software like Eclipse.

- 114,835
- 27
- 73
- 90
I would strongly advise you to use VIM within an IDE (e.g. VIMPlugin and Eclipse - this is the combination I use and it works very well).
I used to be a VIM diehard. However the refactoring and code analysis within a modern IDE will far surpass any capabilities that VIM will provide (with plugins etc.).
Don't get me wrong. I love VIM and still use it for all sorts of stuff. Modern IDEs are the most productive route forward, however.

- 268,207
- 37
- 334
- 440
-
1I've tried those but the vim plugin doesn't give me any of the ide benefits. I might as well just use vim and the ide side by side. – Jeremy Wall Apr 11 '09 at 15:18
-
modern IDEs are to heavyweight. hate waiting almost a minute to open a large project or switch workspaces. – JoaoHornburg Jan 09 '12 at 18:58
I know this is an older question, but I was asking myself this question a bit back and decided to write one. It's new and it not "super awesome yet" but it's written in GOLANG and it's open source. DISCLAIMER, this is my project but I am not self promoting. I just thought I'd share with others that care about something of this nature.

- 542
- 7
- 16
-
-
1All as it is basically a recursive find/replace for both files and the file system – Arash Sharif Jun 25 '14 at 16:14