The eclipse code automatically prompts for settings, how can I configure the code auto-prompt feature of eclipse?

Source: Internet
Author: User

It's not easy for programmers to remember the names of a lot of class names or class methods. If you want the IDE to be able to automatically complete the code, that will be a great help to our programmers.

The Code hints feature in the Eclipse code is turned off by default, only the input "." When the feature is prompted with VS users may not be accustomed to this, VS is the input of any letter will prompt, the following is how to modify the Eclipse configuration, turn on the code automatic prompt function open eclipse-Window, perferences Content Assist, Editor, Java, in the bottom right column find auto-activation, below are three options to find the second "auto Activation triggers for Java:" option after , you will see a "." in the text box. Exist.

This means: only enter "." Then there will be code hints and auto-completion, and that's where we're going to change. put the "." In the text box Replace it with "abcdefghijklmnopqrstuvwxyz." So you can write Java code in Eclipse and press "ABCDEFGHIJKLMNOPQRSTUVWXYZ." Any one of the characters in the box will have code hints.

It's nice to get the code done quickly when writing code with a few characters. But by default, eclipse is the only thing you're typing '. ' (dot character), the Auto Fill window will pop up to give you a choice. This is not enough for most of the time.

Since there are many options in eclipse itself that are turned off by default, developers can only manually configure it themselves.

So how do you configure Eclipse's code auto-hinting feature?

1, window--> preferences--> java--> editor--> Content Assist

1) Tick the check box in the picture

2) The time of auto-completion delay [Auto activation delay (ms)] is 200ms by default, which can shorten the time, for example, I set 2ms.

3) [Auto activation triggers for Java] auto-complete trigger, default is ".", this position can be set to 26 letters plus '. ' :. ABCDEFGHIJKLMNOPQRSTUVWXYZ (case insensitive)

4) [Auto activation triggers for Javadoc]javadoc trigger, default is ' @# '.

2. After the Eclipse code automatic prompt function is set successfully:

However, Eclipse is not allowed to enter such characters, the text box is allowed to enter a maximum of 4 characters, so to modify the configuration file method implementation, the following steps

1. Open eclipse, then "window" → "Preferences"

2. Select "Java", expand, "Editor", and select "Content Assist".

3. Select "Content Assist" and see the "Auto Activation triggers for Java" option under "Auto Activation" on the right. Actually, it means "." is the trigger code hint. This symbol.

4. "Auto Activation triggers for Java" option in "." After the addition of ABC letters, convenient to find the following changes. Then "Apply" and click "OK".

5. Then, "File" → "Export", in the pop-up window select "General" → "perferences", click "Next".

6. Select the export file path, I export to the desktop, enter "ABC" as the file name, click "Save".

7. On the desktop, locate the file "ABC.EPF" that you just saved, and right-select "Open with Notepad."

8. Press "CTRL + F" shortcut key, enter ". ABC" and click "Find Next".

9. Find the configuration information for ". ABC" as follows:

10. Change ". abc" to ". ABCDEFGHIJKLMNOPQRSTUVWXYZ (,", Save, Close "TEST.EPF").

11. Back to the MyEclipse interface, "File" → "Import", in the pop-up window select "Perferences", click "Next", select

Select the "abc.epf" file that you have just modified, click "Open" and click "Finish". This step is similar to the export step above.

12. After the modification, test it on the line.

=========================================================================

OK, next is the point!!! In the following ways, you can completely resolve eclipse to help you automatically complete the variable name!!
1, first find the relevant plugin: Window---Show view->other> plug-ins
Find the plugin org.eclipse.jface.text, right click, select Import as Source project, after the import is complete, you can see this project in your workspace
2. Modify the Code
In the Src/org.eclipse.jface.text.contentassist/completionproposalpopup.java file, find such a line of code (as if it were in line 1335)

char[] triggers= t.gettriggercharacters ();
if (CONTAINS (triggers, key)) {

In that line if judgment, eclipse will determine if key (the key you pressed) is in triggers, and if so, trigger the code on the first line below. So what we're going to do is to exclude the space and the = number:  
if (key! = ' = ' && key! = 0x20 &&contains (triggers,key)) {  
}
code modified so that when prompted to press the space or equal sign, the hint will not fall, It will not be automatically complete!!!
3. Export the modified Org.eclipse.jface.text

You can see the generated jar in the zip file and replace it with the jar of the same name in the Eclipse/plugins.

4. Restart Eclipse.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The eclipse code automatically prompts for settings, how can I configure the code auto-prompt feature of eclipse?

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.