You can use the Templates preference
page to define code templates that enable you to use custom code snippets.
About this task
Custom code snippets (and the shortcuts that invoke them)
are used in conjunction with content assist to type frequently used
code constructs quickly. For example, a predefined code snippet is
provided for the if else statement in the list of available templates.
The shortcut that invokes this code snippet is ifelse.
In the Remote C/C++ Editor, you can type ifelse,
and then press Ctrl + Space to insert the entire
code block for an if else statement into the source file.Note: In the Developer for z/OS® Enterprise
Edition, you will notice two Templates preference pages for C/C++.
The Templates preference page under the z Systems® node is used when editing z/OS UNIX files,
local files in z/OS UNIX projects, PDS members, and sequential
data sets.
Procedure
To set the Remote C/C++ Templates preferences, complete
the following steps:
-
In the navigation pane of the Preferences window, double-click the
Remote C/C++ node to open the tree of available preference pages.
- Double-click the Editor node to
open the tree of available preference pages.
- Double-click the z Systems node
to open the tree of available preferences.
- Click Templates to open the Templates preference
page.
- To create a new template:
- Click New to open the New
Template dialog box.
- In the Name field, type a name
for the new template that you want to create. For example, if you
want to create a template for if else statements, type ifelse.
- Specify the context in which you would
like your template to appear:
- Select C/C++ to have the template appear
in executable C or C++ code in your C or C++ source file.
- Select Comment to have the template appear
when editing comments in your C or C++ source file.
- Select CICS to have the template appear
when editing embedded CICS® statements
in your C or C++ source file.
- Select SQL to have the template appear
when editing embedded SQL in your C or C++ source file.
- Select the Automatically insert check
box to automatically insert the new template if it is the only available
option at the caret position.
- In the Description field, type
a description of the type of code snippet that you want to create
a template for. For example, if else statement.
- In the Pattern field, type the
pattern for your code template. This pattern can contain predefined
and custom template variables. To insert a predefined template variable,
click Insert Variable. From the list of predefined
variables, double-click the variable that you want to include in your
template pattern. You can also insert your own custom template variables
into the template pattern. These must evaluate to the name of the
variable itself. If you want to display the dollar symbol ($), it
must be escaped using two dollar symbols or the ${dollar} variable.
- To edit an existing template:
- Select the template that you want to edit, and then
click Edit to open the Edit Template dialog
box.
- Modify any information that you want to change for the
selected template.
- Click OK to save your changes
and close the dialog box.
Tip: To revert the template back to the default
values that existed before you edited the template, click Revert
to Default.
- To remove an existing template, select the template that
you want to remove and click Remove. The template
is removed from the list of available templates.
Tip: To restore a template that you removed from the list of
available templates, click Restore Removed.
- To import a code template from another location, click Import to
open the Browse dialog box and browse for the
location of the template.
- To export an existing code template to another location,
select the template that you want to export, and then click Export to
open the Browse dialog box. Browse for the location
that you want to export the template to.
Tip: To
export multiple templates to a single XML file, select the first template
that you want to export, and then press Ctrl + click for each additional
template that you want to export.
- Do one of the following:
- Click Restore Defaults to discard your
changes and restore the default settings for this page.
- Click Apply to save your selections
in the preference page.