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.
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.
> 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.
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 :)
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.
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"?
> 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...
Reformatting does not replace spaces with tabs across all supported languages. Groovy, for that matter, does not replace spaces with tabs when you reformat.