Reputation: 87391
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.
Upvotes: 2
Views: 2943
Reputation: 87391
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.
Upvotes: 1
Reputation: 1819
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.
Upvotes: 1
Reputation: 49351
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)
Upvotes: 0