tags:

views:

419

answers:

2

What is the code formating option to indent as:

Log.w(TAG, String.format(
    "Upgrading database from version %s to %s which will destroy all old data",
    oldVersion, newVersion));

instead of as:

Log .w( TAG, String .format( "Upgrading database from version %s to %s which will destroy all old data", oldVersion, newVersion));

A: 

I don't think I've touched my indentation settings and they sure format it like you'd want it to (just tried it). Maybe you can make a fresh Eclipse install and compare settings? I'm using Eclipse 3.4, BTW.

EDIT: No, I take that back. When I tried your sample I had lots of errors and it probably confused Eclipse. Now adjusting the example I get the same as your second (unwanted) example. Sorry for raising any hopes that you could get it fixed. =)

PEZ
+2  A: 

I don't think you'll get what you want in the first block, as Log.w( and String.format( are probably governed by the same formatting rules.

However, you can go to Window->Preferences->Java->Code Style->Formatter and choose to edit. The setting you want to change is on the Line Wrapping tab. If you set Function Calls Line wrapping policy to do not wrap, you get the following.

Log.w(TAG, String.format("Upgrading database from version %s to %s which will destroy all old data", oldVersion, newVersion));
Instantsoup