Eclipse: Java Content Assist & auto activation triggers

The Content Assist feature in Eclipse for Java developers can help you to write your code faster. With help of the autocompletion feature you do not have to type the whole name of sometimes really long class names.

By default Eclipse triggers the autocompletion after a certain delay when you insert a dot. This is sensible because the dot signals the IDE for example that you got an instance of a class and want to call a method on it. You can bring up the autocompletion by manually pressing Cmd plus Space whenever you want.

Let’s have a look at my setup.

Eclipse Content Assist setup

In the Eclipse preferences under Java, Editor and Content Assist I have set the delay for the auto activation to zero milliseconds and inserted the whole alphabet next to the dot in the auto activation triggers for Java input field. This way the auto completion comes up always no matter what key I press.

This is the exact string I use:

.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

A little caveat

This setup can cause Eclipse to stall because it has to lookup all the relevant auto completion proposals on every single keystroke. By default it collects proposals from too many sources – of course this is just my opinion and may be completely different depending on how you use Eclipse.

But if you want to use this setup fluently go to the Eclipse preferences under Java, Editor, Content Assist and the Advanced subsection. Remove all the proposals that you do not really need. In my case I just selected Template Proposals and of course Java source code proposals. This has worked great for me so far.

This setup in action

When you start working on a method and want to add some code just start typing like you normally would and the autocompletion will guide your way. If you think that the autocompletion already got what you wanted to write press Enter and continue typing.

I must admit that the autocompletion can get in your way so you have to maybe have to get in the habit of pressing escape once in a while if you explicitly do not want the current autocompletion.