Eclipse Formatter [message #1073149] |
Wed, 24 July 2013 08:11  |
Eclipse User |
|
|
|
Hi All
I am using eclipse formatter to format some strings that contains sqls inside.
When i write the code as below eclipse formatter is combinining all the string.
String sql = "select * from table" +
"where table.colonA > 0" +
"and table.colonB < 0 ";
After i applied the formatter the string becomes combined as below
String sql = "select * from table where table.colonA > 0 and table.colonB < 0";
Is there a way to prevent this with enabling some parameter in eclipse formatter?
Regards
Murat YILMAZ
|
|
|
Re: Eclipse Formatter [message #1075249 is a reply to message #1073149] |
Mon, 29 July 2013 05:42   |
Eclipse User |
|
|
|
But I do not think there is a problem with the statement interpretation or is there? What I understand is that the semi colon is the one that marks the end of a statement so the 2 versions will be read and interpreted the same way. This is just to make the code neat.
|
|
|
Re: Eclipse Formatter [message #1075458 is a reply to message #1073149] |
Mon, 29 July 2013 13:11  |
Eclipse User |
|
|
|
Eclipse allows you to turn off formatting by placing a special comment, like:
// @formatter:off
...
// @formatter:on
The on/off feature has to be turned on in Eclipse preferences:
Java > Code Style > Formatter.
Click on "Edit" button, go to "Off/On Tags" tab and check "Enable Off/On tags".
You can also change the tags there if required.
So, in your case, enable the on/off feature and place your code that you don't want to be formatted in between the tags:
// @formatter:off
String sql = "select * from table" +
"where table.colonA > 0" +
"and table.colonB < 0 ";
// @formatter:off
|
|
|
Powered by
FUDForum. Page generated in 0.03014 seconds