1. 程式人生 > >Eclipse中設定XML檔案的自動格式化配

Eclipse中設定XML檔案的自動格式化配

  在Eclipse下編輯XML檔案時可以像Java檔案一樣進行格式化。不過,預設的格式化設定效果不太理想,尤其是標籤屬性較多時。
  通過以下設定可以達到一個相對理想的效果:
  Window -> Preferences -> XML ->XML Files -> Editor : 
  • 1.1設定每行寬度
  Line width設定為80到100個字元。
  • 1.2標籤的每個屬性都單獨一行顯示:
  選中Split multiple attributes each on a new line
  • 1.3 標籤結束符不單獨佔用一行:
  不選中Align final bracket in multi-line element tags
  • 1.4去掉所有空行:
  選中Clear all blank lines
  • 1.5 在標籤結束符前新增空格:
  選中Insert whitespace before closing empty end-tags
  • 1.6縮排使用空格代替tab:
  選中Indent using spaces
  • 1.7 設定縮排寬度
  Indentation size 設定為4,即縮排4個空格。