DekGenius.com
Previous Section  < Day Day Up >  Next Section

Recipe 3.13 Automatically Wrapping Strings

3.13.1 Problem

Your text strings are getting too long for the width of the screen, and you're getting tired of scrolling to the ends of the strings to edit them.

3.13.2 Solution

Let Eclipse break the strings for you. Just position the cursor in the quoted text to break, and press Enter.

3.13.3 Discussion

Eclipse handles breaking strings in Java code well. Say you have the following text string:

String text = "This is a long string of text.";

You can put the cursor caret in the middle of the string and press Enter; Eclipse will do the right Java thing by splitting up the quoted text like so:

String text = "This is a long " +
    "string of text.";

You can customize this behavior in the Typing page, which you access by selecting Window Preferences Java Editor Typing.


    Previous Section  < Day Day Up >  Next Section