First you will need to configure how your code is formatted. This can be done by going to
[Main Menu]
-> File
-> Settings
then go to
(Project Settings)
-> Code Style
-> Java
In this area you can define all the formatting rules that you would like to apply to your code.
Now you should check (or change) the keyboard shortcut for reformatting code by going to
[Main Menu]
-> File
-> Settings
then go to
(IDE Settings)
-> Keymap
Just type Reformat Code
into the search box at the top right to find it.
Once this is done, highlight the code you want to reformat and use the keyboard shortcut to reformat your code based on the rules you defined.
ctrl+alt+l
do you get a reformat prompt? just to make sure that something else is not reacting to this shortcut. sometimes it helps to highlight the code first. – Hysterogenicctrl+alt+l
works fine with me. I'm currently using windows 8.1 too. – AnaniasCtrl+Alt+L
orCtrl+Shift+Alt+L
for dialog – Stier