Using Code Templates
See Also
The Source Editor has a set of customizable code templates
for common snippets of C and C++ code. The code templates are
assigned abbreviations to identify them. You type an abbreviation
in your source file, press the Tab key, and the code snippet
from the template is inserted in the file. You can modify, create,
or remove code templates.
To insert a code snippet from a template:
-
Type the abbreviation for the code template and then press the
Tab key to generate the full code snippet.
For example, you can type iff, followed by Tab, to
automatically generate if () {}.
To view all the defined code templates:
-
Choose Tools > Options >.
- Click Editor and select the Code Templates tab.
- Select the language you are working with to view the code templates.
To customize the list of code templates:
-
Choose Tools > Options.
-
Click Editor and select the Code Templates tab.
- Select the language of the code templates you want to customize.
- If you want to change a code template, select a code template from
list and edit the Expanded Text field in the bottom panel.
-
If you want to add a new code template, click New.
- You can use the Expand Template On list to change the
key or key combination that expands the abbreviations.
By default, abbreviations are expanded when you press Tab. The
Expand Template On list also contains the options of Space,
Shift-Space, and Enter.
Copyright © 2014, Oracle and/or its affiliates. All rights reserved.