PyCharm 2.7 Web Help

File | Settings | IDE Settings | File Templates

Ctrl+Alt+SCommand Comma

settings

PyCharm | Preferences | IDE Settings | File Templates

Ctrl+Alt+SCommand Comma

settings

Use this page to view, edit, create, and remove file templates.

File templates are specifications of the contents to be generated when creating a new file. They let you create the source files that already contain some initial code. File templates are written in the Velocity Template Language (VTL).

The toolbar buttons and other controls are common for all the tabs of the page.

Toolbar

ItemTooltipDescription
add.png Create TemplateClick this button to create a new template in the currently opened tab. The button is available in the Templates and Includes tabs.
delete.png Remove TemplateClick this button to delete the selected template. The button is available in the Templates and Includes tabs.
copy.gif Copy TemplateClick this button to create a copy of the selected template. The button is available in the Templates and Includes tabs.
resetProfileToDefault.png Reset to DefaultClick this button to abandon all the changes made to the selected template and restore its default state. The button is available only for modified templates.

Tip

The names of the modified templates are displayed in blue.

Controls

ItemDescription
NameIn this text box, specify the name of the selected template.
ExtensionIn this text box, specify the extension for PyCharm to detect files, where the selected template should be applied during creation.
Reformat according to styleSelect this check box, to have PyCharm reformat generated stub files according to the style defined in the Code Style dialog box.
Template textIn this text box, specify the body of the template:
  • Plain text.
  • #parse directives to work with template includes.
  • Variables to be expanded into corresponding values in the format ${<variable_name>}.

    The available predefined file template variables are:

    • ${PROJECT_NAME} - name of the current project.
    • ${USER} - login name of the current user.
    • ${NAME} - the name of the file that will be created.
    • ${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.
    • ${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.

    Tip

    • To include some Velocity variable in your template that you don't want to be expanded by PyCharm on template applying, prepend it with the '\' character.

      For example, to use some version control keywords (such as $Revision$, $Date$, etc.) in your default class template, you need to prepend them with '\': \$Revision$.

    • PyCharm doesn't prompt for the values of Velocity variables defined with #set.
  • Custom variables. Their names will be defined during the file creation.
DescriptionIn this text box, provide some information about the template, its predefined variables, and the way they work.

Tabs

TabDescription
Templates The tab displays the available file templates.

Note

The HTML/HTML5/XHTML, Python script, Python Unit Test, and Setup Script templates cannot be deleted and their names and extensions cannot be edited.

JavaScript template, if unchanged, can be deleted, but the corresponding Name and Extension fields are disabled.

Includes The tab shows the templates of reusable fragments that may be included in the file templates.

See Also

Concepts:

Procedures:

Web Resources: