san*_*one 71 xml eclipse formatting
当我在Eclipse中编写.xml文件时,我经常需要手动缩进代码.例如
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/background"
android:layout_height="fill_parent"
android:layout_width="fill_parent" />
Run Code Online (Sandbox Code Playgroud)
格式化后,它看起来像这样.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:background="@color/background"
android:layout_height="fill_parent"
android:layout_width="fill_parent" />
Run Code Online (Sandbox Code Playgroud)
如何自动化?我在Eclipse for XML中找不到格式设置.
Den*_*sky 116
Ctrl+ Shift+F
会为你做,你可以配置它
Window -> Preferences -> XML -> Xml Files -> Editor
Run Code Online (Sandbox Code Playgroud)
Pau*_*aul 38
如上所述,Ctrl+ Shift+ F将自动格式化.但是,默认情况下,Eclipse将以天真的方式拆分属性.如果您喜欢我并且喜欢自己拥有所有属性,请转到窗口→首选项→XML→XML文件→编辑器,然后选中在新行上拆分多个属性.