Reputation: 28198
I like to format my code like this:
void someFunction() {
normalLine();
reallyLongLineThatNeedsToBeWrapped(
OnlyIndentOneSpaceHere = true);
normalLine();
}
But from my experimenting with Eclipse's source formatting, it seems that you can't specify wrapped line indentation independently from new block indentation.
Is there a way to accomplish this in Eclipse?
Per answer, I submitted an Eclipse enhancement request.
Upvotes: 3
Views: 3519
Reputation: 6615
Yes and no.
It is possible to indent wrapped lines differently but there is a limitation: Indentation for wrapped lines has to be multiple of indentation for blocks.
You're specifically asking to set block indentation to 3 and line wrap indentation to 1. This particular setup is not possible as of now.
So, what if you want to use, for example, Google Java Style? Their block indentation is 2 and wrapped line (continuation) indent is 4. This is achiavable since 4 is a multiple of 2.
First, open the formatter settings:
Window > Preferences > Java > Code Style > Formatter > Edit
In the Indentation tab, set Indentation size to 2. This is the block indentation.
Then open the Line Wrapping
tab. There you have Default indentation for wrapped lines and Default indentation for array initializers. Set these fields to 2, meaning wrapped lines indentation will be twice the block indentation.
Upvotes: 1
Reputation: 19443
I don't think so. The problem is you can't change the indentation size to be different depending on context. So choosing 1 for the indentation size results in everything being indented by one space. You can have a separate wrapping policy based on it being a function call or not, but the "units" of indentation can't change if it's a function call.
Upvotes: 1