Using Source Code Templates

You can add an existing source code file to your project as a template through the Tools > Options > Environment > Template interface. The Add function displays the Add New Template File dialog box, with which you locate the source code file you want to use as a template. An icon for your template appears in the Customize Template for box in the Tools > Options > Environment > Template interface and in the File > New > File dialog box. After you have added a template to your project, you can modify or delete that file via the Tools > Options > Environment > Template interface. More information about the Tools > Options > Environment > Template dialog box can be found in Template Options.

Another source code template function allows you to insert a small section of frequently used code directly into your text. You define these small templates in the Tools > Options > Code Editor > Code Insight interface. Information about defining code templates in the Tools > Options dialog box can be found in Code Insight Options.

You can insert a small source code template into your source code as follows:

  1. Place the cursor where you want to insert your code template. Choose the Edit > Advanced > Code Template command. A list box containing all currently defined code templates appears.
  2. Browse the list box for the desired template.
  3. Double-click a name; the code template is inserted at the cursor’s location.