RSS
 

Eclipse Tip: Escape text when pasting

10 Mar

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

Related posts:

  1. Eclipse Tip: Auto-generate compilation units by pasting snippets
  2. Eclipse Tip: Navigating stack traces
  3. Eclipse Tip: Format edited lines on Save
  4. Eclipse Tip: Block Selection Mode
  5. AutoHotKey: Paste Plain Text

 
4 Comments

Posted in Eclipse, Java

 
  1. Peter Štibraný

    March 10, 2009 at 1:49 PM

    Very useful. Thanks for sharing!

     
  2. Vasanth Dharmaraj

    March 10, 2009 at 2:03 PM

    @ Peter Štibraný
    You are welcome.

     
  3. Madhu

    March 10, 2009 at 10:27 PM

    Hello Vasanth,

    Thanks for the tip. Its very useful.