• Share this article:

Ctrl+1 in the Eclipse XML Editor

Tuesday, October 20, 2015 - 14:27 by Wayne Beaton

The XML Editor is included in several of the Eclipse IDE downloads. It has two view modes: in design mode, you can edit your XML as a tree; in source mode, you edit as text. By default, it opens in design mode, which may seem a little weird (I’ve added Bug 480036 to the list of EclipseCon Europe 2015 Hackathon bugs to consider changing this).

I use the XML editor infrequently, but it is based on the same technology as the HTML and PHP Editors (which has embedded HTML support) that I use pretty regularly. All three of these editors have a cool feature that I didn’t know existed until today.

Ctrl+1 in the XML Editor

Put the cursor in—or highlight the text of—a tag (either the open or the close tag), and hit ctrl+1. Select “Rename in file” and type a new tag. Both the open and close tags are updated in one. Just like the similar functionality provided by the Java development tools, this is sensitive to context (i.e. it will change the right closing tag).

This is certainly more handy for XML editing, but I did manage to shave a few seconds off my day using it to convert <ol>..</ol> to <ul>..</ul> in some HTML. #littleVictories

For completeness, the XML Editor is already included in  the following Mars Eclipse IDE Packages:

  • Eclipse IDE for Java EE Developers
  • Eclipse IDE for Java Developers
  • Eclipse IDE for PHP Developers
  • Eclipse IDE for Java and DSL Developers
  • Eclipse IDE for RCP and RAP Developers
  • Eclipse IDE for Automotive Software Developers
  • Eclipse IDE for Java and Report Developers
  • Eclipse IDE for Parallel Application Developers

You can add the XML Editor to any Eclipse IDE by adding the “Eclipse XML Editor and Tools” feature from the Mars repository.

Thanks to Konstantin Komissarchik for compiling the list of IDEs and to Nitin Dahyabhai for highlighting the functionality.