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

Vasanth Dharmaraj is a Java Architect currently working for Western Union living in the Bay Area. He is interested in programming, gadgets, formula one... You can follow him on Twitter.

Posted in Eclipse, Java
4 comments on “Eclipse Tip: Escape text when pasting
  1. Very useful. Thanks for sharing!

  2. Madhu says:

    Hello Vasanth,

    Thanks for the tip. Its very useful.

Ads By Google