Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format XML code in Eclipse

When I write .xml files in Eclipse, I often have to manually indent code. For example

<?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" /> 

After formatting it looks like this.

<?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" /> 

How to automate this? I can't find formatting settings in Eclipse for XML.

like image 282
sandalone Avatar asked Dec 24 '10 17:12

sandalone


People also ask

How do I format code in eclipse?

To format your whole script: Open the required file. Go to Source | Format Document or press Ctrl+Shift+F.

How do I format an XML file?

To access XML formatting options, choose Tools > Options > Text Editor > XML, and then choose Formatting.


1 Answers

Ctrl+Shift+F

Will do it for you, and you can configure it in

Window -> Preferences -> XML -> Xml Files -> Editor 
like image 71
Denis Palnitsky Avatar answered Sep 28 '22 07:09

Denis Palnitsky