PyCharm custom file and code template,

Source: Internet
Author: User

PyCharm custom file and code template,

PyCharm provides file and code template functions. You can use this template to quickly create code or files. For example, to create an html file in PyCharm, the new file is not empty, but will automatically fill in some basic necessary content, just like this:

<!DOCTYPE html>

The template content that comes with the system may not be desired. You can modify and add personalized content. For example, if I create a Python file named main. py, the content will be automatically filled in:

# -*- coding: utf-8 -*-"""-------------------------------------------------   File Name:     main.py   Description :   Author :       JHao   date:          2017/4/1-------------------------------------------------   Change Activity:                   2017/4/1:-------------------------------------------------"""__author__ = 'JHao'

The File Name is the File Name, and Author is the username used to log on to the system. The date is the current system date. Does it feel much better than the default blank file. The specific modification steps are as follows: [File] → [Settings], in [Editor) ], find File and Code Templates, and select the File type you want to edit.

My template is like this:

# -*- coding: utf-8 -*-"""-------------------------------------------------   File Name:     ${NAME}   Description :   Author :       ${USER}   date:          ${DATE}-------------------------------------------------   Change Activity:                   ${DATE}:-------------------------------------------------"""__author__ = '${USER}'

Attached template variables:

$ {PROJECT_NAME}-NAME of the current Project; $ {NAME}-NAME of the file specified in the create file dialog box; $ {USER}-current user name; $ {DATE}-current system DATE; $ {TIME}-current system TIME; $ {YEAR}-YEAR; $ {MONTH}-MONTH; $ {DAY}-DAY; $ {HOUR}-HOUR; $ {MINUTE}-MINUTE; $ {PRODUCT_NAME}-name of the IDE for creating a file; $ {MONTH_NAME_SHORT}-abbreviated month, for example, Jan, Feb, etc; $ {MONTH_NAME_FULL}-Full name of the English month, for example, January, February, etc;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.