1. 程式人生 > >eclipse 貼上字串自動新增轉義符

eclipse 貼上字串自動新增轉義符

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,自動轉義。

  1. String xml = <statename="state">
  2.                 <
    paths>
  3.                   <pathto="1"expr="i==1"/>
  4.                   <pathto="2"expr="i==2"/>
  5.                 </paths>
  6.               </state>

變成

String xml = 

  1. String xml = "<state name=\"state\">\n" +   
  2.         "                <paths>\n" +   
  3.         "                  <path to=\"1\" expr=\"i==1\"/>\n"
     +   
  4.         "                  <path to=\"2\" expr=\"i==2\"/>\n" +   
  5.         "                </paths>\n" +   
  6.         "              </state>"