CLion 2016.2 Help

File Template Variables

On this page:

Basics

A file template can contain template variables. When a template is applied, the variables are replaced with their values.

A file template variable is a string that starts with a dollar sign which is followed by the variable name. The variable name may be enclosed in curly braces. For example: $MyVariable or ${MyVariable}.

Predefined template variables

CLion comes with a set of predefined template variables.

The available predefined file template variables are:

  • ${PROJECT_NAME} - the name of the current project.
  • ${FILE_NAME} - the name of the PHP file that will be created.
  • ${NAME} - the name of the new file which you specify in the New File dialog box during the file creation.
  • ${DATE} - the current system date.
  • ${TIME} - the current system time.
  • ${YEAR} - the current year.
  • ${MONTH} - the current month.
  • ${DAY} - the current day of the month.
  • ${HOUR} - the current hour.
  • ${MINUTE} - the current minute.
  • ${PRODUCT_NAME} - the name of the IDE in which the file will be created.
  • ${MONTH_NAME_SHORT} - the first 3 letters of the month name. Example: Jan, Feb, etc.
  • ${MONTH_NAME_FULL} - full name of a month. Example: January, February, etc.
  • $USER_NAME - for OS X users: the registered full name of the user; for Linux and Windows users: the login name of the current user.
  • $HEADER_FILENAME - the name of a header file, generated for a class or a source file.
  • $HEADER_COMMENTS - always returns true and is used for testing purposes.
  • $NAMESPACE_OPEN - indicates the beginning of a namespace block created during refactoring.
  • $NAMESPACE_CLOSE - indicates the end of a namespace block created during refactoring.
  • $INCLUDE_GUARD - prevents from repeated include of the particular header file.
  • $RETURN_TYPE - the type of a function return value and is used for a new functions generation.
  • $DEFAULT_RETURN_VALUE - specifies the default function's return value.
  • $CALL_SUPER - returns the base function call signature during the override generation.
  • $SUIT_NAME - specifies the Google test suite name.
  • $TEST_NAME - specifies the Google test name.
  • $END - indicates the caret position upon finishing the variables editing.

Custom template variables

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

For example, if you want to use your full name instead of your login name defined through the pre-defined variable ${USER}, write 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.

You can prevent treating dollar characters ($) in template variables as prefixes. If you need a dollar character ($ inserted as is, use the ${DS} file template variable instead. When the template is applied, this variable evaluates to a plain dollar character ($).

See Also

Last modified: 22 November 2016