Eclipse – How to auto-format code in Eclipse

code-formattingeclipseformatformatting

How do you auto-format code in Eclipse?

Best Solution

On Windows and Linux : Ctrl + Shift + F

On Mac : + + F

(Alternatively you can press Format in Main Menu > Source)