Friday, 7 December 2012

Escape String literals in eclipse

If you've been using xml literals in your (hopefully only testing) code then you've gone through the pain of escaping the double quotes of all the attributes.

Scala has a great way to handle it using triple - double quotes. In scala this would work fine

val xml = """ <user type="simple"/> """

but if you are stuck with java, then eclipse can escape the string for you..

Go to Window>Preference>Java>Editor>Typing and check the “Escape text when pasting into a string literal

Check this article for some nice screenshots
http://www.vasanth.in/2009/03/10/eclipse-tip-escape-text-when-pasting/


No comments: