tags:

views:

45

answers:

3

When I type class Bar { + Enter, Eclipse 3.5.2 indents the next line, like this (_ is the cursor/caret):

// Eclipse 3.5.2 does this for Java code by default.
// I don't want this (smart indentation).
class Foo {
  class Bar {
    _

How do I disable this so-called smart indentation (for Java code), and revert it back to normal auto-indentation, like this:

// I want this (automatic indentation).
class Foo {
  class Bar {
  _

Without auto indent, it would look like this:

// I don't want this (no indentation)
class Foo {
  class Bar {
_

I can work much more efficiently when I am allowed to manage the indentation, without relying on the possible smartness of the editor. I'm not interested in changing my customs how I edit code, I'm interested in getting rid of the smart indentation feature of Eclipse, and enabling automatic indentation.

I've tried various options in Window / Preferences, but I haven't found any of them which would solve the problem illustrated above.

A: 

Preferences -> Java -> Code Style -> Formatter -> Edit.. (you need to have a non built-in profile which can be changed) -> Identation -> Ident -> Declarations within class body (uncheck)

K. Claszen
This has the unwanted show-stopper side effect that it makes Source / Format unindent all class contents. This is not what I want. What I want is automatic indentation instead of smart indentation when I press Enter to start a new line.
pts
+1  A: 

The Java code formatting options can be found under Windows -> Preferences -> Java -> Code Style -> Formatter. Click the New or Edit button there. This will allow you to modify the "smart formatting" on almost anything in Java. This will only apply to your current workspace. After you have made all your auto-formatting customizations you can "Export" the customization to a file that can be loaded into new workspaces later.

Tansir1
This has the unwanted show-stopper side effect that it makes Source / Format unindent all class contents. This is not what I want. What I want is automatic indentation instead of smart indentation when I press Enter to start a new line.
pts
A: 

It seems that Eclipse 3.5.2 doesn't have the feature I was asking for. Other answers mention workarounds, but those have some show-stopper side effects.

pts