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.
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.)
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.
Minor appology, the allegedly hidden setting can be accessed from Advanced Options dialog under Editor Settings -> Java Editor -> Tab Size.
*** Issue 65454 has been marked as a duplicate of this issue. ***
*** Issue 86750 has been marked as a duplicate of this issue. ***
*** Issue 104265 has been marked as a duplicate of this issue. ***
*** Issue 88167 has been marked as a duplicate of this issue. ***
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
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.