Automatically format sourcecode in Netbeans on save?
Asked Answered
H

2

25

One Feature I miss from Eclipse are Save Actions for autoformatting. Any way to have the same in Netbeans?

Hymnist answered 31/3, 2010 at 5:38 Comment(0)
M
42

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

Munch answered 19/1, 2013 at 17:24 Comment(4)
unfortunately this only removes trailing spaces, it does not apply the code format you'd have defined for the projectBrazilein
Waaaw, it really worked for me too, I didn't know that 7.3 made this important feature, we called for this for yeaaaars!Kitchenware
@Brazilein may have encountered the issue of separate global and project settings. Changes to global options will not affect a project unless the project is configured to use global options. To check a projects formatting (and toggle global/project specific options): Highlight the project in the Projects dialog and Choose: File > Project Properties (or Right click the project and choose Properties) and in the Categories section of the launched dialog, Choose Formatting.Seminole
This option is still at the same place (current NetBeans version: 11.2).Schutzstaffel
L
8

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.

Lepidopterous answered 25/12, 2016 at 20:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.