Auto code completion on Eclipse
Asked Answered
C

14

125

I want Eclipse to automatically suggest to me all possible options, while I'm writing some variable/class name or keyword, like in Flash Develop or Visual Studio.

Is it possible?

If not, with which Java IDE can I get this?

I'm specifically asking about a way to automatically get the same thing I get using CTRL + Space, while I'm typing.

Craigcraighead answered 1/6, 2011 at 13:48 Comment(1)
possible duplicate of Automatically opening completion window in EclipseUppercut
K
263

You can also set auto completion to open automatically while typing.

Go to Preferences > Java > Editor > Content Assist and write .abcdefghijklmnopqrstuvwxyz in the Auto activation triggers for Java field.

See this question for more details.

Keratoplasty answered 1/6, 2011 at 14:45 Comment(5)
I think adding the Capital letters would be handy. I have added ._@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZCorrespond
They should make this the default behavior for eclipse.Lineolate
I can't believe that it's already 2020 when nearly all other Editors and IDEs like VSCode and IDEA already made it default long time ago, Eclipse still needs users to manually set it...Pairs
Also remember to check the box: "Disable insertion triggers except 'Enter'", otherwise, it will annoy you when typingSuffering
@Pairs i thought that its some problem with my system........Hypomania
M
24

Use the Ctrl+Space shortcut for getting all possible autocomplete options available in a particular context in the editor.

Auto Complete will also allow you to insert custom code templates into the editor, with placeholders for various inputs. For instance, attempting to auto complete the word "test" in a Java editor, in the context of a class body, will allow you to create a unit test that uses JUnit; you'll have to code the body of the method though. Some code templates like the former, come out of the box.

Configuration options of interest

  • Auto-activation delay. If the list of auto complete options is taking too long to appear, the delay can be reduced from Windows -> Preferences -> Java -> Editor -> Content Assist -> Auto Activation delay (specify the reduced delay here).
  • Auto activation trigger for Java. Accessible in the same pane, this happens to be the . character by default. When you have just keyed in typeA. and you expect to see relevant members that can be accessed, the auto completion list will automatically popup with the appropriate members, on this trigger.
  • Proposal types. If you do not want to see proposals of a particular variety, you can disable them from Windows -> Preferences -> Java -> Editor -> Content Assist -> Advanced. I typically switch off proposals of most kinds except Java and Template proposals. Hitting Ctrl+Space multiple times will cycle you through proposals of various kinds.
  • Template Proposals. These are different from your run of the mill proposals. You could add your code templates in here; it can be accessed from Windows -> Preferences -> Java -> Editor -> Templates. Configuration of existing templates is allowed and so is addition of new ones. Reserve usage however for the tedious typing tasks that do not have a template yet.
Modulation answered 1/6, 2011 at 13:50 Comment(0)
C
8

Go to Windows--> Preference--->Java--->content assist--->Enable auto activation---(insert ._@abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ in auto activation triggers for java)

Eclipse Preferences

Calculation answered 15/11, 2019 at 1:47 Comment(0)
S
3

Window -> Preferences -> Java -> Editor -> content assist > enter

".abcdefghijklmnopqrstuvwxyz"

in the Auto activation triggers.

It will allow you to complete your code.

Skirmish answered 27/7, 2017 at 6:42 Comment(0)
S
2

CTRL+Space

Spirant answered 1/6, 2011 at 13:52 Comment(0)
D
1

Yes. If the suggestion doesn't compare automatically, then press crtl + space button.

Dulciedulcify answered 1/6, 2011 at 13:50 Comment(0)
S
1

Its simple, these are the steps:

  1. first go to the following settings Window -> Preferences -> Java -> Editor -> content assist -> advanced
  2. there will be two boxes having checkboxes
  3. check everything in there and click apply
  4. now of course when you'll be coding there will be auto code completion feature automatically
Scraggly answered 16/12, 2015 at 5:15 Comment(0)
E
1

Since you asked about other Java IDE, I suggest IntelliJ by JetBrains. Just look at it: not only does it support auto completion as you type, but also it support import package once you select the auto completion.

IntelliJ

Before someone said "Eclipse is free", note that IntelliJ has free community edition as well: www.jetbrains.com/idea/download/

Exedra answered 17/5, 2017 at 4:50 Comment(3)
Eclipse auto-imports too, though.Vedi
Community edition doesn't support enterprise frameworks, but if you don't need it, you can use that too.Isaiasisak
In Eclipse you can enter this url to Install New Software menu: repo.eclipse.org/content/shadows/releases.unzip/org/eclipse/… and select Code Recommenders for Java Developers (you may have issues if others are selected). Once installed, this plugin is very helpful to match the autocomplete with middle letters of your search.Trilbie
C
0

Pressing Ctrl+Space opens up the auto-completion dialog in Eclipse. In the Java Perspective it opens automatically after you typed a . (normally with a short delay).

Corbett answered 1/6, 2011 at 13:50 Comment(0)
M
0

See if your settings are correct also:

Window -> Preferences -> Java -> Editor -> content assist. See if the "completion inserts" is checked off along with anything else there you want to help auto complete.

Marlette answered 1/6, 2011 at 13:52 Comment(0)
P
0

Now in eclipse Neon this feature is present. No need of any special settings or configuation .On Ctrl+Space the code suggestion is available

Pleione answered 17/5, 2017 at 5:41 Comment(1)
Not true. It was present way before Neon!Bianka
N
0

I had a similar issue when I switched from IntellijIDEA to Eclipse. It can be done in the following steps. Go to Window > Preferences > Java > Editor > Content Assist and type ._abcdefghijklmnopqrstuvwxyzS in the Auto activation triggers for Java field

Naumachia answered 14/8, 2019 at 16:50 Comment(0)
S
-1

Steps:

  • In Eclipse, open the code auto completion box from first letter
  • Go to >> Window >> preference >> [ Java c++ php ... ] >> Editor >> Auto activation triggers for...
  • Add the character SPACE by just putting your cursor inside and box and push the space key..

All the commands and variables which begin with that letter are now going to appear

Scoreboard answered 28/10, 2014 at 3:48 Comment(0)
B
-3

Go to Window > Preferences > Java > Editor > Content Assist and write .abcdefghijklmnopqrstuvwxyz in the Auto activation triggers for Java field.

Barograph answered 13/12, 2022 at 9:48 Comment(1)
this is a copy of the accepted answer https://mcmap.net/q/179619/-auto-code-completion-on-eclipse (minus intro and further reading link)Subsistence

© 2022 - 2024 — McMap. All rights reserved.