How to configure Eclipse XML formatting?

I would like to change the way Eclipse formats XML files. For example, if I have in pom.xml file a section as follows:

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>

After ctrl+shift+f it will look like:

    <dependency>
        <groupId>
            junit
        </groupId>
        <artifactId>
            junit
        </artifactId>
        <version>
            3.8.1
        </version>
        <scope>
            test
        </scope>
    </dependency>

I prefer the first version, so how to configure Eclipse to format XML files to look like that?


Window -> Preferences, then XML -> XML Files -> Editor. There is a search box above the preferences tree, very useful when you want to find where something is configured.

Note that it may be some other editor is used, e.g. if you're editing a build.xml file and have the Ant integration. In this specific case you'd set up the formatting at Window -> Preferences, Ant -> Editor -> Formatter. In similiar cases you need to search for the corresponding options for that editor yourself.


I have solution so you should go to Preferences->Andriod->Editors and disable first line "Format XML files using the standard Android XML..." that is the solution. It is connected with instaling ADT plugin I guess.


TRY this

Window->Preferences->XML->XML Files->Editor ... Under Formatting-> Line width

Increase the width value(say 150), until you've desired Tag format