Creating live templates
The following example procedure illustrates how to create a template for a TODO
comment with the current date and user name:
Select the template group where you want to create a new live template (for example, other ). If you do not select a template group, the live template is added to the user group.
Click Add and select Live Template.
-
Specify the following values:
Field
Description
Example value
Abbreviation
Specify the characters to expand the template
todo
Description
Specify an optional description to identify what the template is for
Insert TODO comment with the current date and username
Template text
Specify the body of the template with variables
//TODO $DATE$ $USER$: $END$
Click Define at the bottom to select the applicable contexts (for example, JavaScript if it should apply to Python source files).
-
Click Edit Variables and select the
date()
function for$DATE$
anduser()
for$USER$
. Also select Skip if defined for both variables and click OK. Click OK to apply the changes.
Depending on the current system date and username, the newly created todo
template will expand to a line which is similar to the following:
Create a new template from a fragment of code
In the editor, select the text fragment to create a live template from.
Select user group.
from the main menu. The list of the live templates opens. In this list, the newly created template has been added to theSpecify an abbreviation for the template, an optional description (to identify what the template is for) and modify the template body. If the template has variables defined, click Edit Variables to configure them.
Click OK to apply the changes.
Copy an existing template
If you want to reuse the same template in multiple groups, or you want to create a new template based on another one, you can duplicate an existing template.
On the of the Settings/Preferences dialog (Ctrl+Alt+S), select the template which you want to copy.
pageClick Duplicate on the toolbar. A new template item is added to the same group as the original, and selected.
Specify a new abbreviation for the template, an optional description (to identify what the template is for), and modify the template body if necessary. If the template has variables defined, click Edit Variables to configure them.
Click OK to apply the changes.