CLion 2018.3 Help

Save File as Template Dialog

CLion helps you create file templates from existing files.

Item

Description

Name

Specify the name for the new template as it will appear in the Files tab of the File and Code Templates settings. By default, this field is set to the name of the currently opened file.

Extension

Specify the extension of the file to be created by the new template. By default, this field is set to the extension of the currently opened file.

Template text

Edit the template contents. Here you can use:

  • Plain text.

  • #parse directives to work with template includes.

  • Custom variables. Variables' names can be defined either directly in the template through the #set directive or during the file creation.

    Note that CLion doesn't prompt for the values of Velocity variables defined with #set.

  • Variables to be expanded into corresponding values in the ${<variable_name>} format. The predefined variables that can be used in file templates are described in File Template Variables.

Reformat according to style

Select this checkbox if you prefer CLion to reformat generated stub files according to the style defined on the Code Style page.

This option is only available in the Files tab.

Enable Live Templates

Select this checkbox to use a live template inside a file template. In this case, you will need to put the live template fragments into the Velocity escape syntax. For example:

#[[ $MY_VARIABLE$ $END$ ]]#

This way, you can specify the cursor position. Note that it is required to use the live template variables here.

Description

This read-only field provides information about the template, its predefined variables, and the way they work.

Last modified: 7 December 2018

See Also