Eclipse Tip: Escape text when pasting

When you paste some text in to a string have you seen this?

pasting string 1.png

The problem is that the string is not escaped. This gives you a error. Fixing this is not easy if you have pasted text that needs a lot of escaping. I have encountered this a few times. It is annoying.

Escape text setting.png

Luckily Eclipse has a simple solution for this. Go to Window>Preference>Java>Editor>Typing and check the “Escape text when pasting into a string literal“. Now when you paste the same text here is what you get:

pasting string 2.png

Nice. What would make this feature more discoverable would be when pasting the string an icon should pop up like in Microsoft Word and provide you an option to paste the escaped string…

paste like word.png