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 239037 - Use tabs instead of spaces for formatting
Summary: Use tabs instead of spaces for formatting
Status: NEW
Alias: None
Product: editor
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 7.4
Hardware: All All
: P2 normal with 1 vote (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-02 10:04 UTC by Dalton.Dh
Modified: 2015-04-01 14:48 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments
IDE log (78.61 KB, text/plain)
2013-12-02 10:04 UTC, Dalton.Dh
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dalton.Dh 2013-12-02 10:04:37 UTC
Use tabs instead of spaces for formatting
Eclipse uses tabs for formatting, which makes files much smaller
I want this feature in netbeans.
Plz add it as soon as possible.
If possible put a check box on options -> Editor -> Formatting -> Tabs and intents -> "Use tabs for formatting"
Also add a feature called tab size, which specifies the distance that a tab takes....


Product Version = NetBeans IDE 7.4 (Build 201310111528)
Operating System = Windows 7 version 6.1 running on amd64
Java; VM; Vendor = 1.7.0_45
Runtime = Java HotSpot(TM) 64-Bit Server VM 24.45-b08
Comment 1 Dalton.Dh 2013-12-02 10:04:44 UTC
Created attachment 142776 [details]
IDE log
Comment 2 Dalton.Dh 2013-12-02 10:07:08 UTC
Add tabs in next line instead of tabs
Comment 3 Jiri Prox 2013-12-02 10:10:53 UTC
Both options are already present - they are called Expand Tabs To Spaces and Tab Size
Comment 4 Dalton.Dh 2013-12-02 11:35:22 UTC
/** Sample code which I typed */
package com.dalton.test;

/**
 *
 * @author DaltonD
 */
public class FormatTest {

	public static void main(String[] args) {
		System.out.println("Dalton");
		for (int i = 0; i < 10; i++) {
			System.out.print(i);
			System.out.println(i + 10);
		}
	}
}
/** Sample code which I formatted  */
package com.dalton.test;

/**
 *
 * @author DaltonD
 */
public class FormatTest {

    public static void main(String[] args) {
	for (int i = 0; i < 10; i++) {
	    System.out.println(i);
	}
    }
}
/**
Sample code which I typed contains only tabs for intention
So when I format it, the content of file must remain the same
but as you can see, tab before "public static void main(String[] args) {" and "System.out.println(i);" changed to spaces
In my system,
Expand tabs to spaces is unchecked
Number of spaces per intent is 4
Tab Size is 8

This problem gets fixed if Number of spaces per intent and Tab Size is same
*/
Comment 5 Jiri Prox 2013-12-02 11:41:46 UTC
The problem is indentation level, the formatter is set to 4, but the tab size is set to 8, so it will add spaces if the tab is too long.


To obtain desired formatting style set indentation level to 8
Comment 6 Dalton.Dh 2013-12-02 11:53:44 UTC
I think if Expand tabs to spaces is unchecked then,
'Number of spaces per intent' should change to 'Number of tabs per intent'
Similarly in the case of Continuation Intentation Size, size should be specified as tab count
Also convert existing spaces to tabs during formatting
Comment 7 Jiri Prox 2013-12-02 11:56:50 UTC
No, this way is more flexible
Comment 8 Dalton.Dh 2013-12-02 12:04:34 UTC
ok then
but atleast add a feature to convert spaces to tabs when formatting. Eclipse has this feature
Comment 9 Dalton.Dh 2013-12-02 12:16:31 UTC
convert spaces to tabs, whenever possible (eg:- when Number of spaces per intent and Tab Size is same)
Comment 10 Dalton.Dh 2013-12-02 13:12:10 UTC
Space to tab conversion is working in java files when Number of spaces per intent and Tab Size is same, but with one problem
for continuation intentation there should be 2 tabs. but when i format the source I see only one
In my system (for all language settings and for java. Other languages use all language settings)
Tab Size is 4
Number of spaces per intent is 4
Continuation intentation size is 8

In the case of jsp files, spaces are not getting converted to tabs at all
Comment 11 runiter 2015-03-30 19:41:32 UTC
I like to suggestion that tab option be selected by default instead of space.

It's difficult to navigate code with arrow keys when space is used instead of tabs.

I don't understand why netbean decided to use space, if there is a good reason for it I like to know. All other IDEs use tab by default. Lets follow the standard trend in this case.
Comment 12 Vladimir Voskresensky 2015-04-01 13:01:05 UTC
(In reply to runiter from comment #11)
> I like to suggestion that tab option be selected by default instead of space.
Go To Tools->Options->Editor, Formatting and uncheck "expand Tabs to Spaces"
Then use Tab to insert tab sybmol.
Btw, View->"Show unprintable symbols" also helps to see what is in text
> 
> It's difficult to navigate code with arrow keys when space is used instead
> of tabs.
You can use Ctrl+LEFT/RIGHT to speedup even in text with spaces.
Comment 13 runiter 2015-04-01 14:48:28 UTC
Thanks, I'm aware of all those options that are available. But my point is that by default I shouldn't need to do all that. By default, NetBean should behave like most other IDEs by using tabs. Why put developers though the pain of resetting format option everytime they install netbean in a new computer? Who makes the decision about the default values of these options. I think it should be put to vote.