I was browsing the Android commit tree, as I like to do at 3:20am sometimes, and I just saw a new commit by Tor Norbye with the following description that made my heart skip a beat: "Add autoformatting of XML." This little update may not mean much to the regular folks, but to Android developers, like myself, this has been a long requested feature.

About a year ago, I wrote this article: Auto Formatting Android XML Files With Eclipse, which described how easy it is to achieve uniform, formatted XML files in Eclipse while doing Android development. Since XML files comprise a very large portion of an average Android project (the whole app layout is XML based), keeping XML files tidy becomes a very important, but mundane task.

You see, unlike the Java formatter, there is no option in Eclipse to auto-format XML upon save. Thus, it is left to the developer to not keep firing up the formatter, which quickly gets tiresome.

Here is the full description of the commit, for the interested parties:

This changeset improves the formatting of XML edited by the layout
editor in two ways:

(1) It improves the way the layout editor handles insertion and
deletion into the XML document; it looks up the indentation of the
sibling and parent elements and attempts to correctly indent new
elements based on the existing surrounding formatting, and it also
attempts to clean things up correctly on element deletion.

(2) It adds a new user option for turning on automatic XML
formatting. When this is on, it will invoke the Eclipse XML formatter
on portions of the XML after each edit. This will ensure that the
document adheres to the user's preferred formatting settings (maximum
line width, tabs versus spaces, line breaks before attributes, etc.

Change-Id: I74f9a4240a8c5ca4295c01f3b55751ef10b1c1b0

This change, likely to be released together with the next SDK (Gingerbread), is coming to an Eclipse near you. Hooray!

/end of geek excitement

Source: AOSP git