Type ahead autocompletion in Eclipse

前端 未结 4 462
遥遥无期
遥遥无期 2021-02-02 01:51

Do Eclipse have a plugin for type ahead autocompletion like Visual Studio, so I don\'t have to destroy my spacebar by pressing Ctrl+Space all the time? (If

相关标签:
4条回答
  • 2021-02-02 02:32

    Completion is triggered when pressing ".", if that is what you are referring to as "type-ahead autocompletion". This is what Visual Studio also does, unless you are referring to another Visual Studio feature I'm unaware of.

    Limiting completion to only imported packages I think is a somewhat unorthodox thing to do; you are forced to rely on wildcard imports to define the set of types to complete on. I think most users would consider that less than useful. You're welcome to elaborate on your use case for this, though. For example, why would you want to exclude all Java classes from completion?

    BTW, using "type filters" (as VonC suggests) doesn't require you to add every single class. I typically (globally) exclude java.awt.*, sun.com.*, org.omd.*, and a few others. Eclipse also sorts completion according to a (type-sensitive) heuristic which usually results in the most relevant types being displayed at the top. For example, auto-completion inside a method call will put the variables which matches the method type signature at the top.

    0 讨论(0)
  • 2021-02-02 02:33

    I know that Claus spoke of Java in the second part of his question, but the general question is about any language in Eclipse (no Java tag here), so the following might be of use to python eclipse coders:

    Go to Windows -> Preferences -> PyDev -> Editor -> Code Completion. Here, check the box next to "Request completion on all letter chars and '_'?".

    (Purposefully similar to Cristi's answer.)

    0 讨论(0)
  • 2021-02-02 02:40

    Regarding your second part, yes you can

    • Open Eclipse
    • Select Window/Preferences from the menu
    • Expand Java/Appearance/Type Filters from the menu on the left
    • Click the "Add package" button, enter "java.awt" (without the quotes) and click OK
    • OK your way out

    This will make Eclipse remove any matching classes from the java.awt package from your type ahead list. Very nice...

    So "type-ahead" exists in Eclipse (mentioned in this status report in June 2006), but is synonym of auto-completion, most often triggered by CTRL+ Space... (which is not exactly what you are looking for)


    To be more specific, the kind of automatic auto-completion (completion while you are typing, with a "Common" or "All" list of possible completions) you have in Visual Studio is not there in Eclipse (actually read below):

    alt text

    Original answer January 2010:

    At least, not without a dedicating plugin.
    And even with that plugin, it would have to follow a TemplateCompletionProcessor, meaning it would need a list of characters triggering said completion (again, not what you are looking for), by redefining method getCompletionProposalAutoActivationCharacters().

    Update November 2011:

    Cristi mentions in his answer (upvoted) a great workaround, which consists adding all the letters as Auto activation triggers for java.
    See also "Automatically opening completion window in Eclipse".

    From the thread "Eclipse auto-completion ":

    Windows -> Preferences -> Java -> Editor -> Content Assist
    
    • Set delay to: 0 (actually >0 is better: 50, it avoids CPU picks because of constant listening)
    • Set triggers to:
        .(abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUV WXYZ@
    

    content assist options

    0 讨论(0)
  • 2021-02-02 02:51

    My answer may come too late, but maybe will help others searching this feature in eclipse. This workaround works for me (eclipse helios):

    Go to Windows -> Preferences -> Java -> Editor -> Content Assist. Here, enable Auto activation and set Auto activation delay to a low value, let's say 50 ms. Then comes the workaround: In Auto activation triggers for java, simply put all the characters: abcdefghijklmnopqrstuvwxyz.

    And there you go, just type something.

    0 讨论(0)
提交回复
热议问题