Victor Grazi
Victor Grazi

Reputation: 16490

Compare to Clipboard in Eclipse

I am forced to use Eclipse in a new project, but my heart still longs for IntelliJ which I have been using exclusively since before Eclipse was born.

I am getting used to it, but one feature I really miss is "compare to clipboard".

For example, if you see two similar methods in a class, you can copy one to the clipboard, then compare to the other, and it makes it easy to refactor.

Is there any Eclipse plugin for "Compare to Clipboard"?

Upvotes: 5

Views: 3659

Answers (3)

Jake Toronto
Jake Toronto

Reputation: 3584

Another method, albeit clunky, is to use your version control system's diff tool to do this comparison. Just replace one set of text with the other, save the file, then use your VCS's change tool to see how your file has changed. If you are using the Git plugin for Eclipse, the easiest way to do this is to open the Git Staging view, find your file in the list, and double-click it.

Upvotes: 2

Kellindil
Kellindil

Reputation: 4533

Might not be what you expect to achieve through the compare to clipboard command (I do not know my way around IntelliJ), but you can compare two methods together through the outline view too :

  • Open the Java class containing your methods
  • Select both methods
  • Right-click then use Compare With > Other element...

This will open a comparison dialog displaying the differences between your two methods. This dialog does not allow inline editing, but it is a great way to spot differences between two similar methods.

Note that you can do the same through the package explorer, thus allowing comparison between methods (or inner classes) of distinct java files. For this, you need to make sure that the Package Explorer does not filter the Java Members though. Since I don't really know how to explain that bit other than with images, use the filters view menu (through the downward facing arrow at the top right of the package explorer view) : package explorer menu

and in the dialog that opens, make sure that Java Member is unticked. Then you can simply expand a java class to see its members in the package explorer, and compare them together : enter image description here

Upvotes: 3

Modus Tollens
Modus Tollens

Reputation: 5123

Standard Eclipse does not have a Compare to Clipboard option, but there is an Eclipse plugin which allows you to do that: AnyEdit tools.

I just tried it and it seems to be what you are looking for: it adds the option Compare to Clipboard to the popup menu of the editor and the file explorer views. Comparison is done either on the selected text or the whole file.

Upvotes: 7

Related Questions