We've made a number of improvements to the XML editing experience in Eclipse recently. First of all, there is a brand new formatter. There's a lot to say about it, so I have written a separate entry for it. Second, we've implemented a new custom "smart indent" handler to handle indenting when you insert a newline. Before this, the indentation of the new line would always be the indentation of the previous line. Now, it looks at the surrounding XML context and decides how much to indent the next line. This means that if you for example are editing the attribute list of an element tag that you have not yet closed, the next line will indent one extra level for the indented attributes, and similarly, if you've closed the open tag but haven't added an end tag, it will also indent to the child indentation level. It also handles the special case where you insert a newline between an open and a close tag. In addition to indenting the next line, it also moves the closing tag down an extra line and indents it. Here's an example. Let's say you have this XML: Before, pressing the Return key would edit the document and place the cursor as follows: With our new custom handler, you end up with this instead: Third, we've improved Go to Matching Bracket (which normally jumps between matching parentheses, braces or brackets) such that it works with XML tags as well. When you place the caret anywhere in an open or close tag, it will highlight the opposite open or close tag, and invoking Go to Matching Bracket (Ctrl-Shift-P) will jump to that tag. Here's an example where I've deliberately misplaced the matching closing tag for the open tag, yet you can see its initial character is selected. (Bracket highlighting in Eclipse seems to be limited to a single character even though it would be nice to select the whole closing tag string.) Fourth, we've fixed the default keybindings on Mac such that the Select Enclosing Element actions in XML files have the same keybindings as for Java files. Select Enclosing Element is a quick way in Java files to select the surrounding logical parse tree blocks around the cursor. It turns out Eclipse has this feature for XML files too, but on the Mac it did not have the same keybindings. This should be fixed now such that you can use this to quickly select the surrounding element, or if you select again, its own parent element, and so on. Fifth, the GUI editors now properly create empty tags for elements that cannot have children, so as an example the Layout Editor will now create <Button />, not <Button></Button>. Finally, a number of XML editing bugs were fixed; among them some user reported issues with XML content assist, and an old but difficult to reproduce bug related to undo. Please let us know if you find any bugs or additional corner cases the above features should cover, or if you have other usability enhancements you'd like to see for XML editing Android resource files. |
Recent Changes >