在IntelliJ中重新排序Java类方法的简单方法? [英] Simple way to reorder methods of a Java class in IntelliJ?
问题描述
是否有更简单的方法在IntelliJ中的类源文件中重新排序方法,而不是手动剪切和粘贴代码?现在我经常在重构遗留代码时需要这个,例如在源代码中移动相关的方法彼此接近。
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.
在Eclipse AFAIK中有一个类似于IntelliJ的Structure视图的视图,我可以拖放方法周围。但是,这在IntelliJ中不起作用,我也无法从其帮助中找到任何提示。
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.
我使用IntelliJ 9.0.2是具体的。
I am using IntelliJ 9.0.2 to be specific.
推荐答案
您可以选择方法名称并点击: Ctrl + Shift + < kbd> Up 或 Ctrl + Shift + Down 来上下移动。
You can select a method name and hit: Ctrl+Shift+Up or Ctrl+Shift+Down to move it up and down.
在OS X上: Cmd + Shift + Up 或 Cmd + Shift + 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.
这篇关于在IntelliJ中重新排序Java类方法的简单方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!