Some tips on using Eclipse

1. Common shortcut keys:

  1. Ctrl+o: Quickly display the outline view, which is used to view the method of the current class or a specific method. Press the up and down keys to select an attribute or method, and press Enter will automatically jump to the position of that attribute or method.
  2. Alt+S+V: Select override method.
  3. Alt+S+R: Select and automatically generate get and set methods.
  4. Alt+S+S: Select the return format of the generated toString method.
  5. Alt+S+H: Automatically generate hashCode and equals methods.
  6. Alt+S+A: Automatically generate parameterized constructors.
  7. Alt+S+C: Automatically generate default constructors.
  8. Alt+S+F: Automatic code indentation.
  9. Alt+F+N: Create a new project or file.
  10. Alt+F+C: Close the currently open file.
  11. Alt+F+I: Import project.
  12. Alt+W+P: Open the Preferences window, where you can make some configurations.
  13. Ctrl+1: Display some hints of the line where the cursor is located, such as in the line with a warning, press Ctrl+1 to display some solutions to the hints.


Second, some common configurations:

1. Set the font format:

First Alt+W+P to open the Preferences window, then type Font in the input box, press Enter, select Colors and Fonts, where you can set the format size and color of various fonts, if you just want to set the normal font and size, just Select Basic, then find Text Font and double-click to set the font, font and size. After setting, remember to click Apply to save the settings.


2. Set the code to automatically prompt (by default, the prompt will only pop up when you type '.'):

Similarly, first Alt+W+P to open the Preferences window, open Java-Editor in turn, and then select Content Assist, note that it is selected instead of open. Then in the box behind Auto activation triggers for Java, just type az 26 English letters in it. It doesn't matter if it is upper or lower case. Be careful not to delete the original '.'.


3. Customize some code hints:

I don't know exactly what the actual function of this thing does. For me, sometimes when writing code, I feel like adding a method and calling it here, then I have to write the method first, and then come back to call it. But I am afraid of forgetting, so I want to add a TODO comment here to avoid forgetting. This method is also found on Baidu on the Internet, and the specific source is temporarily unavailable. .

Method: also open the Preferences window, open the Java-Editor in turn, select Templates, and click new to add a custom prompt. For example, for the todo I added, //TODO is filled in Pattern, and description is filled in Description. After setting, type todo in the code and this prompt will pop up.



This function can also be expanded in many ways, and you can customize the code prompts that suit your needs according to your personal needs.


4. Set the annotation format for documentation, overriding methods, etc.:

Similarly, I only used a small part of it - setting the document comment format, you can set your own format according to your own needs. Generally, enter '/**' in front of the class and then press Enter to automatically generate a document comment. Generally, it only indicates the author, and I want to add another time.

Method: Alt+W+P to open the Preferences window, open Java-Code Style in turn, select Code Templates, for my problem, I need to set the type in Comments, and then edit the format you want.




Similarly, I just provide an idea here, you can define your own annotation format according to your own needs.



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325651714&siteId=291194637