How enable auto-format code for Intellij IDEA?


Is it possible in Intellij IDEA after typing ';' or press 'Enter' happened formatting of this string?

For instance, to:



a + b = 10;

Or only possible option: Code > Reformat Code...?

Thank you!

This question is tagged with intellij-idea format reformat

~ Asked on 2013-07-26 10:51:20

The Best Answer is


The formatting shortcuts in Intellij IDEA are :

  • For Windows : Ctrl + Alt + L
  • For Ubuntu : Ctrl + Alt + Windows + L
  • For Mac : ? (Option) + ? (Command) + L

~ Answered on 2013-07-26 11:23:03


I have found two ways to do this:

  1. Go to Settings> Keymap.In the right portion go to Editor Actions> complete current statement.Click on it and select add keyboard shortcut. Press ; and select ok.

  2. Use macro. Go to

Edit> Macros> Start Macro Recording.

Now press semicolon and keyboard shortcut to reformat code (you can find the keyboard shortcut from other answers or from settings > keymap).

After doing reformat go to

Edit> Macros> Stop Macro Recording

Save the macro with a name (auto format or something else). Then go to

Settings> Keymap> Macros> auto format (the macro name).

Click there and select add keyboard shortcut, then press semicolon and click ok. Now whenever you will press semicolon it will write semicolon and do auto format.

~ Answered on 2017-11-04 09:33:35

Most Viewed Questions: