Community
Participate
Working Groups
Build Identifier: 20100917-0705 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. Reproducible: Always
In the Formatter preferences, try this: In Indentation tab, specify the indentation policy as "mixed", and check the box that says "Use spaces to indent wrapped lines". Then in "Line wrapping" tab, select Function calls>Arguments, and then wrapping policy - wrap where necessary, indentation = indent by one. This will indent the arguments inside the long method call starting from one space, which you want. Let me know if this works for you.
Thanks very much Ayushman, but this does not appear to work when I tried it on Indigo 20110916-0149. After following your instructions, if I set indentation size to 3 and tab size to 3 on the indentation tab, the Function calls>Arguments preview looks like this: /** * Arguments */ class Example { void foo() { Other.bar( 100, nested(200, 300, 400, 500, 600, 700, 800, 900)); } } And if I change indentation size to 1 and tab size to 3 on the indentation tab, the Function calls>Arguments preview looks like this: /** * Arguments */ class Example { void foo() { Other.bar( 100, nested(200, 300, 400, 500, 600, 700, 800, 900)); } }
(In reply to comment #2) > Thanks very much Ayushman, but this does not appear to work when I tried it on > Indigo 20110916-0149. Sorry I forgot one step, set the "indentation size" in the "indentation" tab to 1. Now try. :) Please try formatting your code too, instead of just the preview. Thanks.
Thanks again, but are you implying that you believe the preview window is broken? Is there a bug report for that? You must not have read the complete text of my response. I had already explained that I set the indentation size to 1 and kept the tab size 3. Here is some random code formatted with these settings that show the (incorrect) output. It matches the preview window. public void launchMethodInsideLoadingDialog(Activity anActivity, Handler aHandler, int aDialogIdentifier) { myActivity = anActivity; myHandler = aHandler; myDialogIdentifier = aDialogIdentifier; Thread loadingThread = new Thread() { @Override public void run() { myHandler.post(new Runnable() { ...
Ayushman, if you wouldn't mind pasting the code after formatting into a comment on this issue so I can see that you did, in fact, come up with some combination of formatting options that accomplishes the formatting I showed, I'd appreciate it. You could use the standard code shown in the preferences: /** * Arguments */ class Example { void foo() { Other.bar( 100, nested(200, 300, 400, 500, 600, 700, 800, 900)); } }
Created attachment 209185 [details] code snippet
Created attachment 209186 [details] formatter prefs Use these preferences to format the above snippet. This indents the wrapped line to one space after the starting of the method call in the line before. I hope this is what you want.
Sorry I think I now understand your problem. You want to specify the line wrapping indentation NOT in terms of "number of indents" as is currently the case, but in terms of "number of spaces", which may be different from the indentation size. Yes, this is currently not supported, so I'll keep the bug open. Thanks!