tags:

views:

20

answers:

1

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?

+1  A: 

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.

My eclipse formats exactly as your first snippet, not the second.

unbeli
I have examined to settings in the window you mentioned, but there doesn't seem to be a setting affecting the formatting in question.
tputkonen
1- try increasing the line length, maybe it simply does not fit.2- do you have any plugin that handles POM files in eclipse? m2eclipse, etc.?
unbeli
Thanks for the tip. Aptana XML editor was used for editing the file, and it screwed up the formatting. Right click on pom.xml -> open with -> XML editor did the trick
tputkonen