Creating and editing code templates
Code templates are stored in templates.xml in the org.eclipse.cdt.ui and
org.eclipse.jdt.ui folders.
To create a code template:
- Click Window > Preferences.
- Expand C/C++, and click Code Templates.
- Click New.
Do the following:
- In the Name field, enter a template name.
- Click the Context button and select a template type: C or C++.
- In the Description field, enter a description for your new
code template.
- In the Pattern field, enter the code for your template.
- Click Insert Variable to add a variable from the list to the
code you have entered in the Pattern box.
- Click OK.
The new code template is now displayed in the list.
To edit a code template:
- Click Window > Preferences.
- Expand C/C++, and click Code Templates.
- Click Edit. The New Template dialog box opens.
Do the following:
- In the Name field, change the template name to create a new
template based on the current template.
- Click the Context button and select a template type to change the nature of the template.
- In the Description field, change the description of the code
template to reflect your changes.
- In the Pattern field, edit the code.
- Click Insert Variable to add a variable from the list to the
code you have edited in the Pattern box.
- Click OK.
Content Assist
Using Content Assist
Importing and exporting code templates
Code Templates page, Preferences window
Code Templates page