I. Introduction
Recently, I have been practicing algorithm questions to prepare for CCF certification, because it seems that only eclipse can compile Java in the examination room. I have been using idea’s automatic code completion before, and I feel very comfortable. I can customize code snippet templates and quickly enter for(..., Scanner in = ...and so on.
It seems that it is not common to set this up in eclipse, and I couldn't find anything useful online. I spent a long time figuring out how to do it and recording it.
2. Start doing it
打开eclipse,Window-Preference-java-Editor-Templates,
Then click new in the upper right corner,
There are four things on it: Name, Context, Description, Pattern.
Name: code abbreviation used for quick input;
Context: Template context, specifies where the code template can take effect. For Java, it contains at least the following four (we can choose Java by default):
- Java type members. The code corresponding to the template is a class member. Strictly speaking, this should be selected for the psvm template.
- Java statements, the code corresponding to the template is a statement block
- Java, the most versatile, as long as it is Java code
- Java doc, as the name suggests
Description: The prompt displayed when you enter the code abbreviation;
Pattern: the code template corresponding to the code abbreviation;
Note: After entering the template, be sure to click apply
3. Examples
After entering sc, press Enter.