How to escape text when pasting into Eclipse (including XML)

When you paste text into Eclipse it does just that - places where the cursor is in it's full un-altered original form. This is fine most of the time apart from when you might want to copy a chunk of XML (or a similar large body of text). What you end up with in this case is the text pasted in with red lines everywhere because the text hasn't been properly escaped for Java code.

To enable escaping of pasted text open the Preferences panel ('Window' menu -> 'Preferences...' option), then choose: 'Java' -> 'Editor' -> 'Typing' and tick the box which says "Escape text when pasting in a string literal":

Now whenever you post in text which is broken over multiple lines, Eclipse will insert the relevant quotes of Java to make Eclipse happy.

Technorati Tags: , , , , ,

No comments: