Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Eclipse Formatter(Eclipse formatter problem during string formatting)
Eclipse Formatter [message #1073149] Wed, 24 July 2013 08:11 Go to next message
MURAT YILMAZ is currently offline MURAT YILMAZFriend
Messages: 1
Registered: July 2013
Junior Member
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 Go to previous messageGo to next message
Abel Brown is currently offline Abel BrownFriend
Messages: 1
Registered: July 2013
Junior Member
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 Go to previous message
Noopur Gupta is currently offline Noopur GuptaFriend
Messages: 58
Registered: December 2012
Member
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
Previous Topic:Ctrl-2 , X - X does not fire the action
Next Topic:Trouble Setting up Eclipse with Java 1.7 [RESOLVED]
Goto Forum:
  


Current Time: Thu Apr 18 21:37:57 GMT 2024

Powered by FUDForum. Page generated in 0.02282 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top