BrianMc1958
asked on
ECLIPSE NEWBIE: How to preserve line breaks on re-formatting?
Dear Eclipse Experts,
I'm just getting started with Eclipse...
Is there a way to tell the reformatter (Ctrl+Shift+F) to leave line breaks alone? When I have something like:
Do This AND
Do That AND
Do Another
I'd like those to remain on three separate lines. Is that possible?
Thanks!
BrianMc1958
I'm just getting started with Eclipse...
Is there a way to tell the reformatter (Ctrl+Shift+F) to leave line breaks alone? When I have something like:
Do This AND
Do That AND
Do Another
I'd like those to remain on three separate lines. Is that possible?
Thanks!
BrianMc1958
ASKER
Dear radarsh,
Thanks. I'm there, but I'm afraid I can't find what I'm looking for. More specifically, I want this type of statement to retain the line breaks:
String s =
"First Thing " +
"Second Thing " +
"Third Thing ";
I can't find how to do that. I'm sure I'm missing something simple...
--BrianMc1958
Thanks. I'm there, but I'm afraid I can't find what I'm looking for. More specifically, I want this type of statement to retain the line breaks:
String s =
"First Thing " +
"Second Thing " +
"Third Thing ";
I can't find how to do that. I'm sure I'm missing something simple...
--BrianMc1958
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I dont know if this will work or not ,but try it, it just might
String s =
"First Thing \n" +
"Second Thing \n" +
"Third Thing \n";
-Muj ;-)
String s =
"First Thing \n" +
"Second Thing \n" +
"Third Thing \n";
-Muj ;-)
Muj,
That will change the value of the string s itself. Which is undesirable.
Consider a scenario where you have to write a huge query as a static final
String constant. One would want it to be neatly formatted. But, eclipse doesn't
allow us to retain line breaks...
________
radarsh
That will change the value of the string s itself. Which is undesirable.
Consider a scenario where you have to write a huge query as a static final
String constant. One would want it to be neatly formatted. But, eclipse doesn't
allow us to retain line breaks...
________
radarsh
ASKER
Thanks, folks. I'm now seeing that the preserve-line-breaks option was REMOVED from Eclipse a couple years ago. WHY? WHY WHY WHY???
OK. Sorry. Does anyone know a way around this problem? It's actually important to me, as line breaks are sometimes needed to make sections of the code at all readable.
Thanks again,
BrianMc1958
OK. Sorry. Does anyone know a way around this problem? It's actually important to me, as line breaks are sometimes needed to make sections of the code at all readable.
Thanks again,
BrianMc1958
from what I see the string seem to be used for display propers.. and nothing more..
why would you want a line break ...
example:
String s =
"First Thing " +
"Second Thing " +
"Third Thing ";
same as saying String s = "First Thing " + "Secong Thing " + "Third Thing "; //
-Muj ;-)
why would you want a line break ...
example:
String s =
"First Thing " +
"Second Thing " +
"Third Thing ";
same as saying String s = "First Thing " + "Secong Thing " + "Third Thing "; //
-Muj ;-)
ASKER
I often have long Strings that match up field names and field values, like:
...
"FirstField = " + firstField +
"SecondField = " + secondField +
...
...
"FirstField = " + firstField +
"SecondField = " + secondField +
...
Ok I see this is an SQL query .. but along one..
So again what is the problem..
why not just right one long query in a straight line.. normally I do that and dont bother with puting + +..
-Muj ;-)
So again what is the problem..
why not just right one long query in a straight line.. normally I do that and dont bother with puting + +..
-Muj ;-)
>>why not just right one long query in a straight line
That would spoil the readability of the Query!
One thing you can do is, select regions of code you want to format, and hit Ctrl+Shift+F
Do not select the query. This is what even I do sometimes.
________
radarsh
That would spoil the readability of the Query!
One thing you can do is, select regions of code you want to format, and hit Ctrl+Shift+F
Do not select the query. This is what even I do sometimes.
________
radarsh
ASKER
Thanks, folks.
>> That would spoil the readability of the Query!
Normal the IDE should break them up and put + + where ever needed.
Ok here is another suggetion why not split the Long query into small String and + at the end...
example:
String select = "SELECT * FROM WHERE firstField = ";
String ffield = "'+firstField+'";
etc..
String sql = select + ffield + etc...
Only a suggesion ..
-Muj ;-)
Normal the IDE should break them up and put + + where ever needed.
Ok here is another suggetion why not split the Long query into small String and + at the end...
example:
String select = "SELECT * FROM WHERE firstField = ";
String ffield = "'+firstField+'";
etc..
String sql = select + ffield + etc...
Only a suggesion ..
-Muj ;-)
and edit the template. Line breaks can be in different places. You'll have to configure
appropriately.
________
radarsh