Java – Simple way to reorder methods of a Java class in IntelliJ

intellij-ideajavamethodsrefactoring

Is there a simpler way of reordering methods within a class source file in IntelliJ than cutting and pasting the code manually? Nowadays I often need this while refactoring legacy code, e.g. to move related methods close to each other in the source code.

In Eclipse AFAIK there is a view similar to the Structure view of IntelliJ, where I can drag and drop methods around. However, this does not work in IntelliJ and I couldn't find any hints from its help either.

I am using IntelliJ 9.0.2 to be specific.

Best Answer

You can select a method name and hit: Ctrl+Shift+Up or Ctrl+Shift+Down to move it up and down.

On OS X: Cmd+Shift+Up or Cmd+Shift+Down

Beyond this the Rearranger Plugin lets you move methods around quickly, and even define a standard ordering based on your coding convention.