IntelliJ IDEA 13.1.0 Web Help

You can rearrange your code according to your arrangement rules preferences.

To rearrange your code using the arrangement rules
  1. In the editor select a part of the code that you want to rearrange.
  2. On the main menu, choose File | Settings | Project Settings | Code Style .
    Alternatively, use Ctrl+Alt+SCtrl+Alt+SCtrl+Alt+SCtrl+Alt+SCtrl+Alt+SCtrl+Alt+SAlt+F7Ctrl+Alt+SCtrl+Alt+SCommand CommaCommand CommaCommand Comma.
  3. Open Code Style node and select the appropriate language.
  4. On the Arrangement tab of the language settings, specify rules for your code rearrangement and click OK.
  5. On the main menu, choose Code | Rearrange Code.
    Alternatively, on the main menu, choose Code | Reformat Code. In the Reformat Code dialog, select Rearrange entries check box and click OK.

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() {
    }
}

See Also

Reference:

Web Resources: