openfrog
openfrog

Reputation: 40735

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

When I hit Tab for indenting code, I like to get a real tab. Meaning that when I select that, I only have one large thing selected. NetBeans inserts 5 spaces instead of a tab when I hit Tab. Is there a way I can change that?

Upvotes: 121

Views: 78391

Answers (5)

Nanhe Kumar
Nanhe Kumar

Reputation: 16297

Netbeans IDE 8.2 (OSX)

Goto File -> Project Properties (Your Project)

enter image description here

Select Formatting in Categories:

enter image description here

Click on Edit global options.

enter image description here

Then Click on Ok

enter image description here

  • Uncheck : Expand tabs to space.
  • Click on : Apply
  • Click On : Ok

If you want set project specific then :

  • Select : Use project specific options.
  • Uncheck : Expand tabs to space.
  • You can also select Language (PHP)

enter image description here

Then Click on Ok

Upvotes: 1

Álvaro González
Álvaro González

Reputation: 146430

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.

Upvotes: 161

TheSHEEEP
TheSHEEEP

Reputation: 3132

For NetBeans 7.1.2,

I needed to go to Tools -> Options -> Editor -> Expand Tabs to Spaces and uncheck that one (make sure you have "All Languages" selected). And also put an "8" for both Number of Spaces per Indent and Tab Size.

Just having the same value there does not do the trick for me. It must be 8.

Upvotes: 7

grilix
grilix

Reputation: 5341

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]
....

Upvotes: 71

Alexey
Alexey

Reputation: 51

In Tools-> Options-> Editor-> Formatting Expand tabs to spaces should be unchecked and Number of Spaces per Indent should be equal with Tab Size. Also check when you change Language from All languages to other there Override Global Options should be unchecked, too.

Upvotes: 5

Related Questions