Fiachra
Fiachra

Reputation: 135

Eclipse auto suggesting and filling in variable names

Okay, so my issue is when I am creating a variable, lets say for example "Object o" while I am typing "o" it'll suggest something like "object". Which is okay but when I press space it auto fills in the new name. Basically I don't want to turn off auto completion I just want to disable space auto filling the suggestion in. Even to disable variable naming suggestions would work.

I'm using Eclipse Juno Service Release 1.

Upvotes: 12

Views: 13176

Answers (6)

Ghost Ops
Ghost Ops

Reputation: 1734

This is an old question. But, as it doesn't have the solution that actually worked for me, I'm going to put it in here.

You have 2 solutions:

  1. As @Alien said here, you can enable Disable insertion triggers except 'Enter' option to stop eclipse to automatically inserting it. This was my temporary solution.

  2. The answers that suggests disabling certain proposals are onto something. So, I've been tinkering around with those proposals, and strangely, It worked for me. I think this is what @gazzman was trying tell through his answer I guess.

    Go to: Windows > Preferences > Java > Editor > Content Assist > Advanced, and under Default Proposal Kinds, Disable Java Non-Type Proposals, Java Proposals, Java Proposals (Task-Focused), and only enable Java Type Proposals.

    With this, I'm getting no suggestions for variables with their type as suffix. Many people who've answered with this weren't clear at all.

Brief Explanation:

What I've seen in my IDE, Java Non-Type Proposals, Java Proposals and Java Proposals (Task-Focused) are the proposals that are responsible for it.

Explaining with an Example:

In this code, once after I press <tab> right here...

String hi<tab>

Case 1: If you only enable Java Non-Type Proposals, You'll get hiString as a suggestion. (Enabling Java Type Proposals has no change in the output. It'll be the same even if disabled).

case 1 settings

It appears like this:

case 1 output

Case 2: If you enable either/both Java Proposals and Java Proposals (Task-Focused), You'll get hiString as a suggestion (yeah, the same thing).

(All these combinations yield only one suggestion, i.e., hiString)

case 2 settings type 1 case 2 settings type 2 case 2 settings type 3

Here, it appears like this:

case 2 output

Case 3: If you enable Java Non-Type Proposals, Java Proposals and Java Proposals (Task-Focused) altogether, You'll get hiString twice as suggestions.

case 3 settings

And it appears like this:

case 3 output

But after only enabling Java Type Proposals, I don't get any of those suggestions in Default suggestions.

My IDE, on which I've tried it: Eclipse v2024-03 (4.31.0)

Upvotes: 1

Alien
Alien

Reputation: 161

I know it's an old question but since non of the answers here worked for me, and this problem was really annoying me too, I am adding solution that helped me.

In your Eclipse go to: Window/Preferences/Java/Editor/Content Assist

and enable:

Disable insertion triggers except 'Enter'

screen/shotted

Hopefully that will work for everyone!)

Upvotes: 16

Lightfire228
Lightfire228

Reputation: 616

I realize this is a 3 year old post, but...

From what I can gather, there isn't an option to disable this, it was hard coded into the content assist feature. But there is a plugin that you can download from the answer to this stack overflow question that will disable this feature

Upvotes: 1

gazzman
gazzman

Reputation: 1

Window -> Preferences -> Java -> Editor -> Content Assist -> Advanced I turned off Java Type Proposals and made sure Java Proposals is turned on. By the way this is in Spring Tool Suite I haven't checked using eclipse.

Upvotes: 0

gerrytan
gerrytan

Reputation: 41123

As there isn't any definitive solution for this yet, what I find works best is to disable the alphabetic characters from triggers:

Windows > Prefereces > Java > Editor > Content Assist > Auto activation triggers for Java

This will mean no class name / type completion, but method name completion will still be suggested when you pressed dot, however at least Eclipse stop messing with my variable name

Upvotes: 3

rebeliagamer
rebeliagamer

Reputation: 1278

Go to Window/Preferences/Java/Editor/Content Assist and choose settings that works for you.

Upvotes: 1

Related Questions