To reformat code according to the style defined on the Editor | Code Style page of the Settings/Preferences dialog &shortcut:ShowSettings;, select Code | Reformat Code from the main menu.
You can also use Code | Optimize Imports to automatically optimize imports. You can access the corresponding settings on the Editor | General | Auto Import page of the Settings/Preferences dialog &shortcut:ShowSettings;.