Eclipse experiences and skills, eclipse experiences

Source: Internet
Author: User

Eclipse experiences and skills, eclipse experiences

I. Common shortcut keys

1. Alt + ↓: Move the selected code up. You can move one or more lines of code up.

2. Alt + ↓: Move the selected code down. You can move one or more lines of code down.

3. Alt + ↓ left arrow key: the previous edited page

4. Alt + → right arrow key: Next edited page
5. Alt + Shift + S + Generate Getters and Setters...: quickly Generate the get and set methods of variables, which are generally used to customize object classes.

6. Alt + Shift + S + Generate Constructor using Fields...

7. Alt + Shift + S + Generate Constructors from Superclass...: quickly Generate the constructor of the parent class, which is generally used to inherit classes.
8, Ctrl + Shift + O: automatically import all the correct packages
9. Ctrl + E: All opened code files in the current workspace are displayed. You can quickly switch between these code files by entering the first letter to search.
10, Ctrl + 1: quick fix. If there is a red line, move the cursor to the red line and a solution will be prompted.
11. Ctrl + t: quickly list the hierarchy of the currently selected variables or methods

12. Ctrl + Alt + ↓: copy the current row to the next row (copy and add)
13. Ctrl + Alt + ←: copy the current row to the previous row (copy and add)

14. Alt + Enter: displays the attribute search of the selected resource (project or file ).

15. Shift + Enter: insert null rows in the next row of the current row (the mouse can be at any position of the current row, not necessarily at the end)
16. Shift + Ctrl + Enter: insert null rows in the current row (same principle)

17. Ctrl + Shift + X: lowercase for all selected texts
18, Ctrl + Shift + Y: change all selected text to lowercase

19. Ctrl + Shift + P: locate the matched character (for example, {}) (the cursor must be inside the matched character). The effect is similar to that of the double-click mouse, but double-click with the selected effect, this will only let the cursor jump to the matched character position


Ii. Code background color settings

1. Open Window> Preferences> General> Editors> Text Editors> Background color in Eclipse.



2. Shows the color value configuration:




3. After the background color is set to bean paste green, the code editing interface is shown in:




Obviously, this looks much more comfortable than the default pure white background. Of course, you can also set other colors on the background color setting interface to achieve the best eye protection configuration.


3. Add unified comments

1. Open Window> Preferences> Java> Code Style> Code Templates> Comments> Types> Edit in Eclipse.




Edit the pop-up template. By default, there is only one author. You can add other useful parameters, such as date and version.




2. Open Window> Preferences> Java> Code Style> Code Templates> Comments> Files> Edit in Eclipse.

This is to add a comment code for the file. The comment is stored at the top of the file. The first few lines can be used as a copyright statement. For example, if a company has all rights reserved, it is better to add a comment in English. The method is the same as above, the effect is as follows:




3. Return to the workspace. There are two ways to generate the edited code templates.

A. Shortcut: Alt + Shift + J

B. Check Generate comments when creating a class, for example:




4. The effect of the added comment is as follows:



5. Of course, if you are really lazy, you can also directly use the annotation template edited by others to export the xml file, and then import and use


4. Switch between Chinese and English in Eclipse

First, make sure that you have installed the Chinese package. In fact, the Chinese package contains languages in most regions of the world, but only calls the Simplified Chinese
Then, add-nl "region language code" at the destination location of the Eclipse shortcut on the desktop, and start again to switch the language. Chinese: zh_cn; English: EN





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.