2

I am trying to paste a very long string in eclipse like:

String str = "verrrrrrrrry long string that hass 9000 characters";

I want it to appear as
String str = "verrrrrrrrry long"+
             "string that hass "+
             "9000 characters";

I tried the option mentioned here : Paste a multi-line Java String in Eclipse , but that gives me a bunch of new lines inserted in the string which I dont want.

What I am getting currently is a long string that just wraps over itself on the same line.

Any pointers ?

Community
  • 1
  • 1
codeObserver
  • 6,521
  • 16
  • 76
  • 121

3 Answers3

3

Go in your Eclipse preferences:

under Java--> editor --> save actions --> Check off the "Format Srouce code" and "All Lines"

That will wrap it for you, when you save it.

RMT
  • 7,040
  • 4
  • 25
  • 37
  • that did not help exactly. Is it the apropriate combinations of these : editor=>typing=>wrap automatically editor=>typing=>Escape text when pasting into a strin gliteral Java--> editor --> save actions --> Check off the "Format Srouce code" and "All Lines" – codeObserver May 31 '11 at 17:01
  • I meant does all the 3 properties above affect each other , so to get it right I want the correct values for each of them .. The option you mentioned did not wrap it for me, so I was wondering if some other setting is blocking it from doing it. – codeObserver May 31 '11 at 17:04
  • For me the only ones that is checked is: "In String Literals" the "Escape..." is not checked. – RMT May 31 '11 at 17:07
1

You can make a macro on Notepad++ for instance and prepare the string there. After that you just need to paste it to Eclipse.

seth
  • 1,401
  • 1
  • 17
  • 28
1

None of the settings worked for me , though they might be correct and I might have some other issue with my workspace.

Anyways, I was able to work through my problem with this expression:

cat Data.txt  | grep -o -E '.{1,70}' | sed -r 's/(.*)/        "\1"+/'

P.S: If anyone else confirms that one of the answers given by anyone in this post works, I will accept it on their behalf , since I think my answer is not a direct answer to my question.

codeObserver
  • 6,521
  • 16
  • 76
  • 121