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).

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:

Leave a Reply

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

You are commenting using your 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 )

Connecting to %s