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:
- java type members, the template corresponding to the code is a class member, PSVM template Strictly speaking should choose this
- java statements , the code corresponding to the template is a statement block
- java, the most common, as long as the Java code on the line
- 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).
-
- ${cursor} is a representation of the cursor
- ${date} represents the current date string
- ${time} represents the current time string
- ${line_selection} Let the current row be selected
- ${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