You can rearrange your code according to your arrangement rules preferences.
- In the editor select a part of the code that you want to rearrange.
- Open the Settings / Preferences Dialog by choosing for Windows and Linux or for OS X, and click Code Style under Editor.
- Under the node, select the appropriate language.
- On the tab of the language settings, specify rules for your code rearrangement and click .
- On the main menu, choose .
Alternatively, in the project tool window, right-click the file where you want to perform the code rearranging, select . - In the dialog that opens, select check box and click .
Example
Consider the following code that lets you test an arrangement rule that puts fields before methods:
| Before | After |
|---|---|
class Test { public void test(){ } private int i; } class Test2 { public void test(){ } private int i; private int j; } |
class Test { private int i; public void test() { } } class Test2 { private int i; private int j; public void test() { } } |