-->

Validate Autocomplete in Eclipse

2019-06-22 14:11发布

问题:

Coming from Visual Studio and starting a project in Java, I realized I couldn't cope with having to press ctrl+space to have the autocomplete panel show up. An easy workaround was to set all keyboard characters to be trigger characters for autocompletion.

My only problem is that, when presented with autocomplete suggestions, a single press on the space bar will write the first proposition. In situations where I'm happy with the suggestions, that's just fine. In situations where I actually want to use what I wrote down initially, I have to press 'escape' first to remove the autocomplete panel before I can press 'space' safely.

Netbeans doesn't use the space bar as a validating key for autocompletion (only 'enter' does that) and I like that behavior. Any way to replicate it in Eclipse?

Thanks in advance for your answers!

EDIT: I should have mentioned I'm using Eclipse on the Mac.

Guillaume

回答1:

I just tried to reproduce your behavior, but couldn't. Here is the configuration I have (and the steps I have done to reproduce):

  • I have installed Indigo (current version of Eclipse, version number 3.7).
  • I did not change any configuration there, this is what is the default:
  • Under Window > Preferences > Java > Editor > Content Assist, I have the following settings:
    • Completion inserts (instead of overwrite)
    • Insert single proposal automatically (which is ok most of the time)
    • not insert common prefix automatically

I have a simple class, go down to a method, and do the following steps:

  1. Enter this.no and wait some time. Sometimes I have to press CTRL + SPACE, sometimes not.
  2. Proposal pops up which includes notify and notifyAll.
  3. I press SPACE and a space is inserted in the text, the autocomplete suggestions are closed without inserting anything.

I do not know if older versions of eclipse have the same behavior.



回答2:

I have the same problem with Eclipse Indigo on Windows XP actually. Coming from intellij idea, I also felt the need to set the whole keyboard to trigger auto-complete.

A quick proof that SPACE key does accept suggestions : type inte on a new line. If the auto-complete menu shows, press SPACE. It goes for Integer.

If anyone knows how to set the SPACE key to "ignore suggestions", it would be great, because the escape key on my keyboard is also too far away :)

Thanks

Edit : actually the best would be to have only the ENTER key validating, because ';' and '(' also seem to validate