Automatically format sourcecode in Netbeans on save?
Starting with NB 7.3, go to Tools -> Options -> Editor -> On Save
You can select reformat and remove trailing spaces for any language.
You will need to specify the reformat option to "all lines" if you want it to format all of your code
For Netbeans 8.2 running on Mac. Here are the steps.
1.Click Netbeans --> Preferences
2.Click on the "Editor" tab
3.In the Editor tab click on the "On Save" tab.
4.Click on the Reformat Combo Box and select the option "all lines"
Thats it, you are done.