Changing the behavior of the Eclipse auto-complete (Content Assist)
Asked Answered
Q

3

7

When I am programming in Eclipse, the auto-complete \ suggestions box usually opens when typing a dot (for example after typing System. or SomeObject., and stays open while typing a similar code to any of the suggested.

This is what I'm talking about: enter image description here

I often use the auto-complete \ suggestions box to my advantage, and there are couple of changes I would like to make in order to improve my productivity while programming, if possible;


  • Is there any way to make the suggestions box visible all the time, showing suggestions in real-time (and showing a blank box when there are no available suggestions) ?

  • Is there any way to add permanent custom suggestions to the suggestions box (e.g. a switch case template or a line of code like public String toString()) ?

  • Is there any way to re-order the suggestions box (e.g. class private variables before general functions or System.out.println() before System.out.print()) ?

  • Is there any way to re-design the suggestions box - i.e changing its text color, background color, re-sizing the suggestions box window and removing the yellow java-doc pop-up?

Quadric answered 21/7, 2012 at 8:57 Comment(1)
look at this link for custom template #1029358Bus
R
9

FYI, in Eclipse terminology this feature is called Content Assist.

Is there any way to make the suggestions box visible all the time, showing suggestions in real-time (and showing a blank box when there are no available suggestions) ?

No, that's not possible. You can invoke it any time you want via Ctrl+Space (Command+Space on Mac)

Is there any way to add permanent custom suggestions to the suggestions box (e.g. a switch case template or a line of code like public String toString()) ?

Yes, you can add your own templates via Preferences > Java > Editor > Templates

Is there any way to re-order the suggestions box (e.g. class private variables before general functions or System.out.println() before System.out.print()) ?

Not really. There is some control of the order for "cycling" through proposal types via Preferences > Java > Content Assist > Advanced, but it's not really what you're looking for. The order of proposals is, I think, based on the current context of when Content Assist is invoked.

Is there any way to re-design the suggestions box - i.e changing its text color, background color, re-sizing the suggestions box window and removing the yellow java-doc pop-up?

All of the customization option are available under Preferences > Java > Content Assist; color options are available under Preferences > General > Appearance > Color and Fonts, but I think the colors for that pop-up might come from your operating system color settings.

If you're using (or willing to use) Eclipse Juno (4.2) then there is a new project call Code Recommenders that you might find interesting.

Roundhouse answered 21/7, 2012 at 14:2 Comment(1)
Hey, from a different stackoverflow thread that I can't find I learned you can add more auto activation triggers and include all letters, like this: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz. This makes the suggestions show up pretty much immediately, thought sometimes this can be annoying I like it so far.Chewning
B
8

E-Riz already answered all your other questions but for getting content assist in real-time there is a workaround

Under Preferences > Java > Editor > Content Assist there is an option for "Auto activation triggers for Java". By default it's set to ".". You can append to that all the alphabets (ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz) and then it should work.

Baroness answered 14/3, 2013 at 14:58 Comment(2)
Thanks for your comment! It's a shame that an IDE like Eclipse do not have a feature like this.Tenotomy
yea I agree. This should have been the default behavior instead of having to do it this wayBaroness
D
2

Is there any way to re-design the suggestions box - i.e changing its text color, background color, re-sizing the suggestions box window and removing the yellow java-doc pop-up?

Just when the auto-suggestion box pops up, if you hover your mouse pointer to its botton-right corner, you'll be able to see mouse pointer turn into resize pointer. Resize it the way you like and next time when it pops up, it will be of the same size. Hope this helps. :-)

Disillusionize answered 16/3, 2016 at 12:18 Comment(1)
You're a life saver.Hermit

© 2022 - 2024 — McMap. All rights reserved.