When you first open the Live Template outline, the name=" " field is highlighted, and the cursor is located between the two double-quotes (name="|").

Note: You can use the Tool Palette to open the Live Template XML outline in the Code Editor. Enter template in the search field on the Tool Palette, and either press Enter or double-click Code Template.

Provide Attribute Values in the XML

Now fill in the fields in the template; you can add specific fields that are needed for your template.

Start by assigning your template a name. The template name and code language fields in the template are required.

In the invoke field, specify how this template will be invoked:

manual - invoked by pressing TAB

auto - invoked by pressing SPACE or TAB

none - invoked by using CTRL+J, CTRL+SPACE, or using the Templates Window

Fill in the description, author, and code language attributes (language="Object Pascal" or language="C").

Define Any Jump Points

Jump points are optional navigable placeholders for entry fields. If you want your template to contain these placeholders, then you need to define a point for each entry field in the template. When anyone uses the template, they can jump from point to point using the Tab key or Space bar.

To define jump points in your template:

Position the cursor (jump points are typically the first elements defined in a Live Template, and so should be located before the <description> field).

Double-click the point template, which is available in the Templates Window when you are creating a Live Template.

The point template is displayed at the cursor location in the Code Editor:

Each point has three attribute values:

PointName defines the name of the jump point.

PointText defines the descriptive text displayed in the Templates Window. (In the Code Editor, the jump point erroneously displays PointName, but the actual XML for point is correct.)

PointHint defines the popup hint for the point.

that are defined as jump points in this template. For each point, these attribute values define
the name, text (the description displayed in the Templates Window) and a hint (that pops up when you mouse-over a template in the Templates Window.

Enter the Code and Save the Template

Type in the code for your template, inside the nested brackets ([ ]) in the <![CDATA[]]> tag.

For example, here is the XML for the point template itself. point.xml contains three points (PointName, PointText, PointHint), and you can see the code representation of the point template inside <![CDATA[]]>:

<?xml version="1.0" encoding="utf-8" ?><codetemplatexmlns="http://schemas.borland.com/Delphi/2005/codetemplates"version="1.0.0"><templatename="point"invoke="manual"><description>
Create a point in code templates
</description><author>
Embarcadero
</author><pointname="PointName"><text>
PointName
</text><hint>
Name of the point
</hint></point><pointname="PointText"><text>
PointText
</text><hint>
Text for the point
</hint></point><pointname="PointHint"><text>
PointHint
</text><hint>
Text for the point's hint
</hint></point><codelanguage="XML"delimiter="|"><![CDATA['''<point name="|PointName|">|*|<text>|*||*||PointName||*|</text>|*|<hint>|*||*||PointHint||*|</hint></point>|end|''']]></code></template></codetemplate>

2. Choose the Save command from the File pull-down menu in the Code Editor (or type CTRL + S). Your new template now appears in the tree of the Templates Window.

Templates are saved, by default, into the C:\Users\<user>\Documents\Studio\code_templates directory; they must be saved into this directory for them to appear in the Templates list in the IDE.