How can I configure NetBeans to insert tabs instead of a bunch of spaces?

Go to Tools-> Options-> Editor-> Formatting and uncheck Expand tabs to spaces:

Expand Tabs to Spaces

Ensure you also pick coherent values for "Number of Spaces per indent" and "Tab Size".


Additionally, you can check all the items in the Language combo and make sure they all use the general setting.

Use All Languages Setting

You can also change it in a per-project fashion. Right click on the project icon, select Properties and review the Formatting category.

Use project specific options

These menu items remain valid as of NetBeans 8.0.


It seems to work if you select the same value for "Number of Spaces per Indent" and "Tab Size", after unchecking the "Expand Tabs to Spaces" Option, in Tools -> Options -> Editor -> Formatting, for example:

[ ] Expand Tabs to Spaces

Number of Spaces per Indent: [ 4]
Tab Size:                    [ 4]
....