Eclipse Custom code Templates

Source: Internet
Author: User

Eclipse Custom code Templates

Eclipse provides a lot of code templates that we can get through windows->preferences->java->editor->templates (you can enter Templates find in the search box) See a list of all defined code templates.

We select the Sysout template in the pop-up window and click on the right edit to display the following:

The edit panel is the core object of interest, first to familiarize yourself with the key five items in this panel.

    • name: name, code abbreviation to be used later
    • Context: template context, where the template is in effect, contains at least such four for Java:
      1. java type members, the template corresponding to the code is a class member, PSVM template Strictly speaking should choose this
      2. java statements , the code corresponding to the template is a statement block
      3. java, the most common, as long as the Java code on the line
      4. java Doc, document comment
    • Pattern: Code template corresponding to the pattern, according to the format of the code you want to input can be
      • Template variable: eclipse has preset some template variables (point insert varibles can see all preset variables).
      1. ${cursor} is a representation of the cursor
      2. ${date} represents the current date string
      3. ${time} represents the current time string
      4. ${line_selection} Let the current row be selected
      5. ${word_selection} Let the current Word be selected

Of course we can also define our own template variables, such as I define a ${mytemplatevarible}, then the corresponding code shows that the mytemplatevarible

For more custom code template content you can select Java Editor Template Var by clicking the Help Contents option in the Help menu and typing "Java Editor template Variables" on the search bar of the popup dialog box Iables See the specific document description:

Eclipse Custom code Templates

Related Article

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.