Eclipse has an option so that copy-paste of multi-line text into String literals will result in quoted newlines:
Preferences/Java/Editor/Typing/ "Escape text when pasting into a string literal"
添加一个字符串到eclipse里面,自动加上转义
比如给一个String 赋值 一段xml,自动转义。
- String xml = <state name="state">
- <paths>
- <path to="1" expr="i==1"/>
- <path to="2" expr="i==2"/>
- </paths>
- </state>
变成
String xml =
- String xml = "<state name=\"state\">\n" +
- " <paths>\n" +
- " <path to=\"1\" expr=\"i==1\"/>\n" +
- " <path to=\"2\" expr=\"i==2\"/>\n" +
- " </paths>\n" +
- " </state>";