Before you start
This tutorial covers the benefits of Eclipse templates, including direct integration with auto-competition, the ability to use predefined and custom variables, context sensitivity, and the enhanced predictability and validity of code. It also shows how to create, edit, and delete templates, how to create a new file using a template, and how to use templates within the editor. Finally, the tutorial provides and some tips and tricks for getting the most out of your templates.
Template functionality varies by plug-in. It would be impossible to cover all the specifics for every plug-in that supports templates in a single tutorial, so to keep things as general as possible, we examine templates in the context of the Web HTML editor plug-in. I chose this because HTML is a simple language and the templates that come with this plug-in are simple and easy to use. Even if you don't have the plug-in installed, the concepts you learn will still be applicable to using templates in general. You can then takes these concepts and apply them to the templates for your specific plug-in.
After completing this tutorial, you will be able to:
- Locate templates in the Preferences pane.
- Explain what a template context is.
- Use a template to create a new file.
- Use templates in the Editor window.
- Create you own templates.
- Use variables in templates.
This tutorial assumes basic familiarity with the Eclipse IDE and that you know how to perform tasks such as setting up a workspace, creating projects and files, and switching perspectives and views.
The examples were created in Eclipse V3.4 (Ganymede), but the instructions apply to V3.2 (Europa) and are most likely applicable to versions older than that. In addition to the Eclipse IDE, this tutorial requires the Web Tools Platform (WTP) plug-in (see Resources to find Eclipse and WTP).