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 66187 - Allow access to all settings concerning use of tabs/spaces for indentation
Summary: Allow access to all settings concerning use of tabs/spaces for indentation
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: Formatting & Indentation (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: issues@editor
URL:
Keywords:
: 65454 86750 88167 104265 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-10-06 23:57 UTC by janicki
Modified: 2007-11-05 13:39 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description janicki 2005-10-06 23:57:52 UTC
I changed my preferences to tab size=2, and *not* expanding to spaces.  

When I open a java file, all preexisting tabs are rendered at size=8, but any new tabs I enter (via tab key) 
are rendered as 2 spaces.  

As a temporary workaround, I can cut/paste a real tab, which gets left alone as a tab, (renderered at 
size=8, like the rest of the real tabs).  

(Netbeans v4 worked as expected.)
Comment 1 Vitezslav Stejskal 2007-01-10 02:49:21 UTC
Yeah, the indentation settings are not very intuitive. The important thing to
remember is that 'Number of spaces per indent' is not a tab size. It's just what
it says it is - a number of spaces per indent. I have no clue what an indent is
and how the IDE desides when I am just writing a tab and when I am 'indenting'.
But apparently those two situations produce different results.

In the first situation (just writing a tab) the IDE will insert a tab character
in a document and it will be rendered 8 spaces wide (according to a setting that
can't be modified).

The second situation is a tricky one, because it may insert a tab character or a
bunch of spaces or (!) a mixture of this depending on how big the 'Number of
spaces per indent' (NOSPI) is comparing to 8 (the value of that hidden setting
from the first situation). Here is what happens:

- NOSPI < 8 - you will get a bunch of spaces according to the value of the NOSPI
setting
- NOSPI == 8 - you will get a tab character
- NOSPI > 8 - you will get 'NOSPI div 8' tab characters and 'NOSPI mod 8' spaces

If you still haven't got enough, here is more. If you keep indenting (ie.
pressing a tab key in the second situation) the total size of your indent will
be the number of times you pressed a tab key multiplied by NOSPI. No magic here,
but this total size is than used for applying the above rules. So, in your
situation with NOSPI = 2, you will get 2, 4 and 6 spaces after you press a tab
key ones, twice and three times. If you press it forth time, all the spaces will
be magically transformed to a single tab character. Wow!!!

What is all this good for? Hmm, nobody knows, but the rumor is that it's exactly
what Vi does. 
Comment 2 Vitezslav Stejskal 2007-01-10 03:14:15 UTC
Minor appology, the allegedly hidden setting can be accessed from Advanced
Options dialog under Editor Settings -> Java Editor -> Tab Size.
Comment 3 Vitezslav Stejskal 2007-04-16 05:02:57 UTC
*** Issue 65454 has been marked as a duplicate of this issue. ***
Comment 4 Vitezslav Stejskal 2007-05-21 01:17:31 UTC
*** Issue 86750 has been marked as a duplicate of this issue. ***
Comment 5 Vitezslav Stejskal 2007-05-21 01:36:01 UTC
*** Issue 104265 has been marked as a duplicate of this issue. ***
Comment 6 Vitezslav Stejskal 2007-07-18 18:17:59 UTC
*** Issue 88167 has been marked as a duplicate of this issue. ***
Comment 7 Vitezslav Stejskal 2007-07-18 18:28:05 UTC
Should work better now. The default indentation settings panel in Tools-Options -> Editor -> Indentation shows only the
three generic settings: tab size, number of spaces per indent and expand tabs to spaces.


Checking in indentationExample;
/cvs/editor/options/src/org/netbeans/modules/options/indentation/indentationExample,v  <--  indentationExample
new revision: 1.4; previous revision: 1.3
done
Checking in Bundle.properties;
/cvs/editor/options/src/org/netbeans/modules/options/indentation/Bundle.properties,v  <--  Bundle.properties
new revision: 1.8; previous revision: 1.7
done
Checking in IndentationModel.java;
/cvs/editor/options/src/org/netbeans/modules/options/indentation/IndentationModel.java,v  <--  IndentationModel.java
new revision: 1.10; previous revision: 1.9
done
Checking in IndentationPanel.form;
/cvs/editor/options/src/org/netbeans/modules/options/indentation/IndentationPanel.form,v  <--  IndentationPanel.form
new revision: 1.3; previous revision: 1.2
done
Checking in IndentationPanel.java;
/cvs/editor/options/src/org/netbeans/modules/options/indentation/IndentationPanel.java,v  <--  IndentationPanel.java
new revision: 1.26; previous revision: 1.25
done
Comment 8 swpalmer 2007-09-27 19:33:17 UTC
I want to indent with tabs, never spaces.  But when I press tabs I get spaces inserted regardless of the "expand..."
setting.

This is with a NB 6 daily after Beta1 (200709025).

We may have access to the settings, but they don't work properly.  If you want to indent with tab characters there are a
few bugs that cause spaces to be used instead.   Some edits will magically replace the spaces with tab characters - like
if you go to the end of the previous line and press delete-enter, then the indentation for the following line will be
converted from spaces to tabs.