IntelliJ IDEA 2021.2 Help

File template variables

A file template can contain variables, which are replaced by their values when the template is applied. A variable is a string that starts with a dollar sign $ 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:

Variable

Description

${DATE}

Current system date

${DAY}

Current day of the month

${DIR_PATH}

Path to the directory of the new file from the content root

${DS}

Dollar sign $. This variable is used to escape the dollar character, so that it is not treated as a prefix of a template variable.

${FILE_NAME}

Name of the new PHP file (if the PHP plugin is enabled)

${HOUR}

Current hour

${MINUTE}

Current minute

${SECOND}

Current second

${MONTH}

Current month

${MONTH_NAME_FULL}

Full name of the current month (January, February, and so on)

${MONTH_NAME_SHORT}

First three letters of the current month name (Jan, Feb, and so on)

${NAME}

Name of the new entity (file, class, interface, and so on)

${PACKAGE_NAME}

Name of the target package where the new class or interface file is created

${PRODUCT_NAME}

Name of the IDE (for example, IntelliJ IDEA)

${PROJECT_NAME}

Name of the current project

${TIME}

Current system time

${USER}

Login name of the current 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, IntelliJ IDEA will ask you to specify it when the template is applied.

Last modified: 02 August 2022