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?
- 7Tabstops of 5 is really unusual.Anon.– Anon.2009-12-22 20:42:23 +00:00Commented Dec 22, 2009 at 20:42
- 4The size of a tab is just an opinion, but actually inserting spaces is the most stupid thing you can do if you ask me.timing– timing2013-03-01 13:18:52 +00:00Commented Mar 1, 2013 at 13:18
- 11"Using only spaces, and not mixing spaces with tabs, helps to avoid problems with diffs, patches, history, and annotations. The use of spaces also makes it easy to insert fine-grained sub-indentation for inter-line alignment." github.com/php-fig/fig-standards/blob/master/accepted/…leticia– leticia2013-09-06 20:47:40 +00:00Commented Sep 6, 2013 at 20:47
- 5The PSR-2-coding-style-guide says "Code MUST use 4 spaces for indenting, not tabs." as the previous commenter mentioned. It's just good to be aware when you're diverging from standards.Camden S.– Camden S.2014-01-20 17:52:51 +00:00Commented Jan 20, 2014 at 17:52
- 5Isn't the PSR standard for PHP? Why does netbeans force it on everything? Tab is more natural and intuitive.... you use space for space and use tab for indentingNoobification– Noobification2014-11-02 13:40:45 +00:00Commented Nov 2, 2014 at 13:40
5 Answers
Go to Tools-> Options-> Editor-> Formatting and uncheck 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.

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

These menu items remain valid as of NetBeans 8.0.
11 Comments
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] ....
6 Comments
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.
Comments
Netbeans IDE 8.2 (OSX)
Goto File -> Project Properties (Your Project)
Select Formatting in Categories:
Click on Edit global options.
Then Click on Ok
- 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)
Then Click on Ok




