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 the
Tab 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:
- In the Code Editor, choose ViewTemplates .
- Expand the tree in the Template Manager for the language you are using, by clicking the plus sign in front of language name.
- Put the cursor at the place in your code where you want to add the template.
- Choose the template you want to use in the Template Manager window.
- 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:
- Place your cursor at a jump point in your template.
- Pres Ctrl + Space to invoke the Code Completion window.
To surround text with a template using the mouse:
- Select the code in the Code Editor that you want the template to surround.
- Click the right mouse button and choose the Surround command. This will give you a choice of 'surround-able' templates.
- Choose a template from the list.
To surround text with a template using the Template Manager window:
- In the Code Editor, choose ViewTemplates.
- Expand the tree in the Template Manager for the language you are using, by clicking the plus sign in front of language name.
- Choose the template you want to use in the Template Manager window.
- Select the code in the Code Editor that you want the template to surround.
- Click the Execute button in the Template Manager window.