IDEA Chapter 4 ---- configuration template, idea Chapter 4 ----

Source: Internet
Author: User

IDEA Chapter 4 ---- configuration template, idea Chapter 4 ----

Idea provides many templates to improve the efficiency of code writing, such as some frequently used code and templates for file generation.

Section 1: Real-Time Code Template

As the name implies, a real-time code template means that you can enter a fixed letter in a program to quickly generate the code you want. For example, press the Tab key to automatically generate a System. out. println (); and many others include java, jsp, xml, css, etc. Idea has many built-in templates which are not introduced here. idea also supports custom templates and template groups, all of which are under live templates, the Custom template can quickly generate the desired Code, for example, the method annotation template file annotation template.

Create a dynamic template Group

  

  

Define your own template and template description as well as the Code style to be output by the template. use $ to spell the parameters.

  

Select the applicable scope of the dynamic Template

  

Edit the parameters in the Code, the selected after the mouse does not stop, idea comes with a lot of built-in functions, you can refer to the official website Introduction: https://www.jetbrains.com/help/idea/2017.1/creating-and-editing-template-variables.html

  

Set the template for method annotation. There is no fixed format. You can follow your company's rules.

  

The default date and time functions are not formatted, but the output format is not friendly. Therefore, you can output the time format based on your preferences (which is quite useful for patients with obsessive-compulsive disorder)

  

The real-time code template of IntelliJ IDEA is saved in the/templates directory. After you enter sys, press the Tab key to generate a preset statement immediately. If you press Ctrl + J, the system will first prompt the introduction of the matching Real-Time code template, and then press Enter to generate the default statement.

Section 2: file template

Many file types can be defined below. We will take the class as an example.

  

Idea built-in variables are not described here.

  • $ {PACKAGE_NAME}-the name of the target package where the new class or interface will be created.
  • $ {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.
  • $ {USER}-the login name of the current user.
  • $ {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.
Section 3: Postfix Completion

The Postfix Completion function is essentially a code template, but it is a little more convenient than Live Templates. It is also easy to understand. I will not introduce it more here.

  

 

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.