Tabs vs spaces in Netbeans


I work with some people that like spaces and some people that like tabs in their code. I don’t really care, so I try to follow whatever the project is using. I ran into a big problem with Netbeans, though, in that it seems like getting it to use tabs only is impossible. It turns out they appear to be following a weird part of the Java Code Conventions spec:

Four spaces should be used as the unit of indentation. The exact construction of the indentation (spaces vs. tabs) is unspecified. Tabs must be set exactly every 8 spaces (not 4).

http://java.sun.com/docs/codeconv/html/CodeConventions.doc3.html#262

So, Netbeans sort of has two different “numbers” around tabs. There is a number that says how many spaces a tab should appear as, and a number that says how many spaces should be used when you indent something. By default a tab appears as 8 spaces, but a level of indentation is 4 (like the spec says above). As a result, it inserts four hard spaces when you indent one level, and a tab if you indent two levels. The solution is to set the two numbers to the same value. Just a wee bit confusing for a new user.

Here’s a bug report where someone describes it:

http://www.netbeans.org/issues/show_bug.cgi?id=52053

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s