Eclipse auto-completion Enhancement

Source: Internet
Author: User

In the process of using eclispe, I feel that automatic completion is not good, and VS is not powerful. The following are two methods for auto-completion enhancement:

 

1. added the eclipse prompt function.

In eclipse, under window> preferences> JAVA> editor> content assist> auto-activation ". add the first subtitle that we need to prompt automatically after ", for example," ABC ". You can add all the uppercase and lowercase letters (. abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz _).

2. Modify the shortcut key for auto-completion

First, open eclipse, open window-> show view, select plug-ins, and find Org. eclipse. jface. text, right-click, and select import as-> source project. After the import is complete, you can see the project in your workspace.

There is a piece of code in the "org. Eclipse. jface. Text. contentassist. completionproposalpopup # verifykey ()" function under the Import project:

// key != 0        switch (key) {            case 0x1B: // Esc                e.doit= false;                hide();                break;            case '\n': // Ctrl-Enter on w2k            case '\r': // Enter                e.doit= false;                insertSelectedProposalWithMask(e.stateMask);                break;            case '\t':                e.doit= false;                fProposalShell.setFocus();                return false;            default:                ICompletionProposal p= getSelectedProposal();                if (p instanceof ICompletionProposalExtension) {                    ICompletionProposalExtension t= (ICompletionProposalExtension) p;                    char[] triggers= t.getTriggerCharacters();                    if (contains(triggers, key)) {                        e.doit= false;                        hide();                        insertProposal(p, key, e.stateMask, fContentAssistSubjectControlAdapter.getSelectedRange().x);                    }            }        }

 

Modify this code:

        // key != 0        switch (key) {            case 0x1B: // Esc                e.doit= false;                hide();                break;            case '\n': // Ctrl-Enter on w2k            case '\r': // Enter                e.doit= false;                insertSelectedProposalWithMask(e.stateMask);                break;            case '\t':                e.doit= false;                insertSelectedProposalWithMask(e.stateMask);                break;            default:                ICompletionProposal p= getSelectedProposal();                if (p instanceof ICompletionProposalExtension) {                    ICompletionProposalExtension t= (ICompletionProposalExtension) p;                    char[] triggers= t.getTriggerCharacters();                    if (key!='='&&key!=0x20&&key!='.'&&key!=';'&&contains(triggers, key)) {                        e.doit= false;                        hide();                        insertProposal(p, key, e.stateMask, fContentAssistSubjectControlAdapter.getSelectedRange().x);                    }            }        }

 

This will cancel the auto-completion of "=", space, ".", and ";", and add the tab auto-completion.

Finally, export the modified plug-in. Right-click the project in your workspace, select export-> deployable plugins and fragments, click Next, select the destination tab, and select directory, select a directory to save the plug-in, and then finish it. A zip package is displayed, and a jar package is displayed in plugins, replace the file with the same name in the Plugins under the eclipse directory (you 'd better first put the org. eclipse. jface. text_3.7.2.v20111213-1208.jar (because different versions of eclipse may have different names for this file) backups ).

 

It will be nice to use eclipse after modification!

 

 

20:49:38

The default Tab key is used to locate the next parameter in auto-completion.

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.