Ctrl+1 in the Eclipse XML Editor

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.

This entry was posted in Eclipse 101, Hackathon and tagged , . Bookmark the permalink.

One Response to Ctrl+1 in the Eclipse XML Editor

  1. jmini says:

    Nice post and nice feature…

    I once have looked for this feature:
    * ALT+Shift+R => does nothing.
    * Context Menu on selection > Refactor => the menu is empty. I was looking for a “Rename Element…” Menu entry.

    I am a big user of CTRL+Shift+1 in the java editor. Now I know that I can try it in the XML editor to…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s