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 143795 - Convert spaces to tab
Summary: Convert spaces to tab
Status: REOPENED
Alias: None
Product: editor
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker with 2 votes (vote)
Assignee: Dusan Balek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-08-13 18:24 UTC by _ gtzabari
Modified: 2015-12-22 22:34 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ gtzabari 2008-08-13 18:24:04 UTC
Netbeans has a feature "Expand tab to spaces" but not the other way around. That is, I'd like Netbeans to collapse X
spaces into a tab character.

As far as I understand it the line of reasoning for choosing spaces or tabs goes as follows:

1) If tabs are used, each user can choose their own tab size. The downside is that some editors default to a tab size of
8 spaces (which is unreadable) and don't let you reconfigure it.

2) If spaces are used, the file looks "good enough" across all editors but imposes one person's style on everyone else.

Netbeans implements approach #2, I'm asking for approach #1.
Comment 1 Vitezslav Stejskal 2008-08-18 10:42:42 UTC
> Netbeans has a feature "Expand tab to spaces" but not the other way around.

It's not a feature, it's a setting, which tells the editor what to do when you insert tab in a document or how to
reformat your files.


> Netbeans implements approach #2, I'm asking for approach #1.

No, you can choose what you want by changing the formatting settings. Then you can reformat your files to use your
formatting settings.
Comment 2 _ gtzabari 2008-08-18 15:42:19 UTC
vstejskal,

As far as I know, there is no way to tell Netbeans to collapse X whitespace characters into a tab when reformatting the
file. WORKSFORME implies that this is already implemented. If this is the case, please point out how to configure this
behavior; otherwise please leave the issue open. Thank you :)
Comment 3 Petr Dvorak 2008-08-18 17:52:17 UTC
Hi! Go to Tools>Options>Editor>Formatting. Select Java in the Language combobox and TabsAndIndents in the Category
combo. Uncheck expand tabs to spaces, set TabSize to 4. Then, if you go to some source file, press Shift+Alt+F
(reformat). Each 4 spaces will be replaced by the tabs (right?). Is this what you would like to see? ;) Petr D.
Comment 4 _ gtzabari 2008-08-18 17:57:38 UTC
I stand corrected. Thanks Petr!

It wasn't obvious to me that unchecking "expand tabs to spaces" implies "compress spaces to tabs". Is there a way we can
improve the UI to make this more obvious? Perhaps replace the checkbox with a radio-button where you either select
"expand tabs to spaces" or "compress spaces to tabs"?
Comment 5 Petr Dvorak 2008-08-18 18:07:04 UTC
> Perhaps replace the checkbox with a radio-button where you either select "expand tabs to spaces" or "compress spaces
to tabs"?

This might work quite nicely actually...

There is probably a problem with a point of view on the "Expand tabs to spaces" feature. The problem is that most people
would think about "Expand tabs to spaces" as about a "replace chars" feature more than about "general formatting"
feature. It is not about replacing/contracting some characters at all. Simply - if you check the checkbox, you say "I
would like to format all my source using several spaces instead of tabs". If you uncheck it, you say "I want tabs to be
used for the formatting". You do not say anything like "Please replace all my spaces/tabs because I like it better for
some mysterious reason".

I can understand that IDE does not say this at the moment - your radio buttons would be probably more
descriptive/explanatory...
Comment 6 MarkFlacy 2015-12-22 22:34:48 UTC
Reformatting does not replace spaces with tabs across all supported languages. Groovy, for that matter, does not replace spaces with tabs when you reformat.