This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 236598 - Expand tabs to spaces does not work
Summary: Expand tabs to spaces does not work
Status: NEW
Alias: None
Product: editor
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 7.4
Hardware: PC Windows 7
: P3 normal (vote)
Assignee: Dusan Balek
Depends on: 239409
  Show dependency tree
Reported: 2013-10-01 12:45 UTC by Jiri Prox
Modified: 2016-02-02 12:08 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Prox 2013-10-01 12:45:26 UTC
Expand tabs to spaces does not work in HTML editor. It does not matter if it is set at All Language level or just only for HTML

Steps to reproduce:
1) have a html file
2) disable expand tabs to spaces
3) reformat file

-> spaces are not replaced by tabs

Product Version: NetBeans IDE 7.4 RC2 (Build 201309302222)
Java: 1.7.0_45; Java HotSpot(TM) 64-Bit Server VM 24.45-b08
Runtime: Java(TM) SE Runtime Environment 1.7.0_45-b14
System: Windows 7 version 6.1 running on amd64; Cp1250; en_US (nb)
User directory: C:\Users\jprox\AppData\Roaming\NetBeans\7.4rc2
Cache directory: C:\Users\jprox\AppData\Local\NetBeans\Cache\7.4rc2
Comment 1 Ondrej Brejla 2013-12-12 11:41:58 UTC
Yes it doesn't work. But it's correct behavior imho. All other languages behave incorrectly as well, because that option doesn't say that disabling "Expand tabs to spaces" means "Transform spaces to tabulators". It just says "No tabs will be expanded to spaces".

And if it doesn't work that way (and it works as you described), then text of that option must be modified.
Comment 2 berniev 2014-05-11 15:55:47 UTC
There is an issue here and imho the supplied answer is wrong. 
Tested in php, IDE 8.0, Mac OS X. I've been using NB for 6+ years and this trips me up each new installation.

Using the defaults of
  Spaces per Indent: 4
  Tab Size: 8
can cause confusion.

Entering a tab at the beginning of a line generates four spaces (prove by backspacing).

Entering a second tab those spaces are replaced by one tab 8 chars wide, again prove by a single backspace removing.

Reason: It appears NB does not use some internal method to differentiate indents from tabs, so if Spaces per Indent is not equal to Tab Size then the difference can only be represented by spaces. Under default settings spaces ARE generated for odd number tab entries i.e 1st, 3rd etc.

Usability: Removing spaces when a tab is expected is a PITA, and the inconsistency of sometimes spaces and sometimes tabs is annoying.

Workaround: Change Tab Size to be same as Spaces per Indent. Formatting DOES then change all those indent spaces back to tabs.

Possible fix: Change default Tab Size to 4 to match that popular indent size. Does losing the 8-char tab (which is the norm) affect something else? I think an 8 char indent is not popular?
Comment 3 otisjenkins85 2016-02-02 12:08:59 UTC
I am using Netbeans 8.1 and after almost an hour of fiddling with the settings I cannot find any way of pressing tab to create spaces.  Also when I auto format Netbeans replaces all of the spaces with tabs (the exact opposite of what I want to happen), regardless of what settings I choose, on PHP, HTML or All Languages.  This is incredibly frustrating, and surely must be a bug?