Reputation: 4802
How to configure Eclipse to format all java code except Strings declaration?
Example:
Before Ctrl+I:
String sql =
"Select column " +
"from table " +
" where column1 > 0 AND column2 < 0";
After Ctrl+I:
String sql = "Select column " + "from table "
+ " where column1 > 0 AND column2 < 0";
Thank you!
edit:
Has any way to configure using Formatter preferences (Window > Preferences > Java > Code Style > Formatter)?
Upvotes: 0
Views: 117
Reputation: 64444
You can enable the @formatter:on
and @formatter:off
tags in the formatter preferences:
// @formatter:off
String s = "..." +
"..." ...
// @formatter:on
Upvotes: 1
Reputation: 66283
You could use //
to prevent the formatting like this:
String sql = //
"Select column " + //
"from table " + //
" where column1 > 0 AND column2 < 0";
That's not very nice but works in every case (i.e. when your coworkers don't use exactly the same settings in Eclipse).
Upvotes: 1