Creating and editing code templates
Content Assist uses code templates enable you to use commonly used code snippets quickly.
To create a code template:
- Click Window > Preferences.
- Expand C/C++, and click Code Templates.
- Click New.
Do the following: (if required)
- In the Name field, enter a template name.
- Select Structure, Global or Function for either C or C++ from the Context drop down list.
- 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.
- Select Structure, Global or Function for either C or C++ from the Context drop down list to select where the template will appear.
- 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