RAD Studio (Common)
ContentsIndex
PreviousUpNext
Using Live Templates

Live templates are reusable code statements that are accessible from the Code Editor. You can insert pre-defined code segments into your code or add your own code snippets to the Template window.

Note: If a template has one or more jump points that are editable, it will automatically enter SyncEdit mode when you are inserting it into your code. The jump points allow you to navigate between different areas of the template, using the Tab
key and SHIFT+Tab keys. Pressing ESC, Enter,(or pressing theTab key) from the last jump point exits SyncEdit mode and puts the Code Editor back into regular edit mode. See the link at the end of this topic for more information about SyncEdit.

To insert an existing Live Template into your code:

  1. In the Code Editor, choose ViewTemplates .
  2. Expand the tree in the Template Manager for the language you are using, by clicking the plus sign in front of language name.
  3. Put the cursor at the place in your code where you want to add the template.
  4. Choose the template you want to use in the Template Manager window.
  5. Click the Execute button in the Template Manager window.
After you have inserted a template, you will probably need to fill in data, variables, methods, or other information that is specific to your code. You can use the Code Completion feature with some of the templates, as described below.

To use Code Completion with your template:

  1. Place your cursor at a jump point in your template.
  2. Pres Ctrl + Space to invoke the Code Completion window.

To surround text with a template using the mouse:

  1. Select the code in the Code Editor that you want the template to surround.
  2. Click the right mouse button and choose the Surround command. This will give you a choice of 'surround-able' templates.
  3. Choose a template from the list.

To surround text with a template using the Template Manager window:

  1. In the Code Editor, choose ViewTemplates.
  2. Expand the tree in the Template Manager for the language you are using, by clicking the plus sign in front of language name.
  3. Choose the template you want to use in the Template Manager window.
  4. Select the code in the Code Editor that you want the template to surround.
  5. Click the Execute button in the Template Manager window.

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!