Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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"?

like image 737
Victor Grazi Avatar asked Dec 30 '12 00:12

Victor Grazi


2 Answers

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.

like image 90
Modus Tollens Avatar answered Sep 25 '22 13:09

Modus Tollens


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

like image 41
Kellindil Avatar answered Sep 22 '22 13:09

Kellindil