Setting code formatting preferences
-
From the workbench menu bar, select Window > Preferences. The Workbench Preferences page opens.
-
In the left pane, expand the Java category and select Code Formatter. The Code Formatter Preferences page opens.
-
Select a profile and click the Show or Edit button to configure it, or press New to create a new profile.
-
In the dialog, select the code formatting conventions that you want the formatter to follow.
-
Note that at the right side of the page, you can observe an example effect of each individual code formatting option and see a preview of what your formatted code will look
like.
-
Click OK when you are done.
Note: Code formatter settings can also be configured per project:
-
Select a java project, open the pop-up menu and choose Properties.
-
Select the Code Style > Formatter page and check Enable project specific sttings.
-
Select or edit a profile as explained above.
-
Click OK when you are done.
Java development tools (JDT)
Formatting Java code
Formatting files or portions of code
Code Formatter preferences