eclipse format code code example

Example 1: eclipse formatter off

// @formatter:off
...
// @formatter:on

Example 2: eclipse format on save

To enable it, do the following:

    Go to Window > Preferences > Java > Editor > Save Actions.
    Select Perform the selected actions on save.
    Select Format Source code. ...
    Make sure Organize imports are selected.
    Select Additional actions.
    Click Ok, edit some code, save it and watch Eclipse format it automatically.

Example 3: eclipse shortcut core formating

To format your whole script:

Open the required file.

Go to Source | Format Document or press Ctrl+Shift+F.

Tags:

Misc Example