Adding a Block Comment Keybinding to the ANT editor in Eclipse

Friday, December 2, 2011

If you’re like me, you keep your hands off the mouse and know your IDE intimately. You use shortcuts (keybindings) whenever possible, and if you find yourself reaching for the mouse, you stop and you try to find the shortcut.

Turns out, Eclipse’s ANT editor doesn’t seem to have a keybinding for inserting block comments (<!-- -->). Fortunately, if your Eclipse install has a plugin such as the WTP HTML editor  or ColdFusion Builder which includes a “Insert Block Comment” action, then you can easily bind that editor’s action to the ANT editor, thereby getting block comment insertion in ANT build files with a keyboard shortcut. Here’s how:

Binding a Block Comment to a keyboard shortcut

  1. Window – Preferences
  2. Filter on “keys” to get to the keybinding property sheet
  3. In the keybinding sheet, type “html comment” in the filter
  4. If your editor supports it, one or more  rows will appear. Highlight one of them.
  5. Click “Copy Command”
  6. In the copied command, down in the “Binding” field, type a keystroke you want to use. I like ctrl+shift+M
  7. In the “When” dropdown, select “Editing Ant Buildfiles”
  8. Click “OK” and get out of all that.

ant_keybinding

Now, when editing an ANT file, you can use your shortcut to insert block comments.

--Marc

1 comment:

Erica White said...

Thanks for all these shortcut keys you provided. I'll be using it in my job in the seo in Philippines so I'll become more productive.