The end of the Eclipse tutorial (on)

Eclipse install plugin

Find and install plugins

As an integrated IDE development tool, Eclipse provides convenience for our software development. In addition to its own powerful functions, Eclipse also supports feature-rich plug-ins.

We can find and download the plug-ins we need through the official Eclipse market ( Eclipse Plugins, Bundles and Products - Eclipse Marketplace ).

For example, we can find plug-ins that support Python IDE, as shown in the following figure:

In Eclipse IDE, we can also find plug-ins by clicking the Eclipse Marketplace (Eclipse supermarket) option in the Help menu:

In the figure above, we choose PyDev to let Eclipse support Python development, we only need to click the Install button. The following dialog box is the plug-in selected for installation.

You can also install plugins by clicking the Install New Software menu item on the Help menu: 

In this way we need to know the remote installation address of the plugin, you can submit the URL by clicking the Add button.

The list of remotely installable plugins is listed in the install dialog:

Eclipse code templates

Use code templates

Eclipse provides the ability to improve productivity and code predictability by defining and using code templates.

We often need to write the main method in the process of developing Java programs:

public static void main(String[]args) {

}

If we write letters one by one, it will be a repetitive and meaningless thing, so we can use Eclipse code templates to quickly complete these tasks.

We only need to type main in the class body, and then use Eclipse's code prompt shortcut key (the default is Alt+/), and after pressing Enter, we can see that Eclipse automatically completes the complete definition of the main function for us:

If we want to use System.out.println(), we just need to type syso and press Alt+/:


Custom Code Templates

Eclipse also provides a lot of code templates, we can see a list of all defined code templates through Windows->Preferences->Java->Editor->Templates (you can enter Templates in the search box to find).

We select the sysout template in the pop-up window and click Edit on the right, as shown below:

The edit panel is the core focus, since everything is configured there. Let's get familiar with the five key items in this panel.

  • Name: the name, which is actually the abbreviation of the code that can be used in the future
  • Context: Template context, specifying where the code template can take effect, including at least four of these for Java:
    • Java type members, the code corresponding to the template is a class member, strictly speaking, the psvm template should choose this
    • Java statements, the code corresponding to the template is a statement block
    • Java, the most general, as long as it is Java code
    • Java doc, as the name suggests
  • Template variables: eclipse has preset some template variables (click Insert Varibles to see all preset variables), such as:
    • ${cursor} is the cursor
    • ${date} represents the current date string
    • ${time} represents the current time string
    • ${line_selection} makes the current line selected
    • ${word_selection} makes the current word selected
    Of course, we can also define our own template variables. For example, if I define a ${myTemplateVarible}, the corresponding code will display myTemplateVarible.
  • Pattern: The pattern corresponding to the code template, just input one by one according to the format you want the code

For more custom code template content, you can click the Help Contents option in the Help menu, enter "Java Editor Template Variables" in the search bar of the pop-up dialog box, and select Java Editor Template Variables to view the specific document description:

 

Guess you like

Origin blog.csdn.net/slave_of_life/article/details/130969582