CLion 2018.1 Help

File Template Variables

A file template can contain variables, which are replaced by their values. A variable is a string that starts with the dollar sign ($) and followed by the variable name. The variable name may optionally be enclosed in curly braces. For example: $MyVariable and ${MyVariable} are different notations of the same variable.

Predefined template variables

The following predefined variables can be used in file templates:

${CALL_SUPER}Base function call signature during the override generation
${DATE}Current system date
${DAY}Current day of the month
${DEFAULT_RETURN_VALUE}Default return value of the function
${DS}Dollar character ($). This variable can be used to escape the dollar character, so it is not treated as a prefix of a variable.
${END}Caret position after you finish editing the variables
${FILE_NAME}Name of the new C or C++ file
${HEADER_COMMENTS}Always returns true and is used for testing purposes
${HEADER_FILENAME}Name of the header file generated for a class or a source file
${HOUR}Current hour
${INCLUDE_GUARD}Prevents repeated include of a particular header file
${MINUTE}Current minute
${MONTH}Current month
${MONTH_NAME_FULL}Full name of the current month (January, February, etc.)
${MONTH_NAME_SHORT}First three letters of the current month name (Jan, Feb, etc.)
${NAME}Name of the new entity (file, class, interface, and so on)
${NAMESPACE_CLOSE}End of a namespace block created during refactoring
${NAMESPACE_OPEN}Beginning of a namespace block created during refactoring
${PRODUCT_NAME}Name of the IDE (for example, CLion)
${PROJECT_NAME}Name of the current project
${RETURN_TYPE}Type of the function's return value (used for generating new functions)
${SUIT_NAME}Google test suite name
${TEST_NAME}Google test name
${TIME}Current system time

For Windows and Linux: login name of the current user

For macOS: registered full name of the user

${YEAR}Current year

Custom template variables

Besides predefined template variables, it is possible to specify custom variables. If necessary, you can define the values of custom variables right in the template using the #set directive.

For example, if you want to use your full name instead of your login name defined through the predefined variable ${USER}, use the following construct:

#set( $MyName = "John Smith" )

If the value of a variable is not defined in the template, CLion will ask you to specify it when the template is applied.

Last modified: 24 July 2018