Ctrl-Space in Eclipse without Pressing Ctrl-Space - eclipse

I've just started using Eclipse and I noticed that when I start typing a local variable name it doesn't come up with suggestions like Visual Studio does until I press Ctrl+Space. Is there any way to get it to do this automatically? I find Ctrl+Space an awkward key press.

These bugs (and a solution if you use Eclipse >3.4) may be of interest to you:
A. Allow more character triggers as #Samuel said (fixed in 3.4 onwards):
https://bugs.eclipse.org/bugs/show_bug.cgi?id=159157
Change the default in Auto activation triggers for Java to ._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
B. Allow content assist everywhere automatically (not fixed):
https://bugs.eclipse.org/bugs/show_bug.cgi?id=101420

What works:
Change the Auto activation triggers to .abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_
You're unlikely to type anything else to get assist started.

Window -> Preferences
Java -> Editor -> Content Assist
Change auto-activation to suit your preferences
You will probably want to set the delay to 0.

Also to make Auto Complete work in XML files do the following changes in
Preferences -> XML -> XML Files -> Editor -> Content Assist
Under Auto Activation section, provide the following values
Make Auto activation delay (ms): 0
Prompt when these characters are inserted: <=:._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
Following screenshot explains the same

Related

How can I keep Eclipse from filling in auto-completions when I type an opening parenthesis ('(')?

So, on Eclipse Luna, I often encounter the situation where I'm typing a method name, but the first autocomplete suggestion is not the method I am looking for but something that is prefix-equivalent but longer, as in this example:
In the example, I just wanted the element(String name) method, so instead of hitting Return, I type ( instead. The result, quite annoyingly, is this:
This is clearly not what I was looking for. Is there a way to prevent Eclipse from performing auto-complete when I hit open-parenthesis (()?
These are my content assist settings (aparrently, I don't have code recommenders installed at all in this eclipse installation):
In Eclipse 4.11 (2019-03), and possibly earlier, the answer to this is under Preferences → Java → Editor → Content Assist → Disable insertion triggers except 'Enter'. After I checked that box, editing became a lot less annoying.
I have no idea why Eclipse doesn't do it by default. Who types map.put( and wants that to autocomplete to map.compute()?
A hack for this is to change the way Eclipse sorts the proposals.
You can go to Preferences menu and then go to the section for which you want to edit sorting. Then to de Editor section and Content Assist.
For example, for Java editor, it will be Preferences > Java > Editor > Content Assist.
There you will see, more or less in the middle of the window, a section called Sorting and filtering. Inside there is an option called Sort proposalswhich you can change from by relevance to alphabetically. Save an close.
With this you will get the proposals list order alphabetically and element() will be before other methods starting by element.
EDIT:
Tested in Eclipse Luna running in Ubuntu 14.04 and it works. You'll still get your code completed when writing ( but it will be completed with the shorter option available in the proposals list. If you want to use another method, you can continue writing some letters and the shortest option will disapear of proposals as it doesn't match what you are writing.
I guess your problem is the substring matches.
Go Window->Preferences->Java->Editor>Content Assist.
In Sort proposals section uncheck Show substring matches.
I found By relevance more useful then Alphabetically.
I have usually checked hidden Hide proposals not visible in the invocation target, and Hide deprecated references, too.
I hope it help.
The feature you're fighting with is the new "Intelligent code completion" which orders methods based on average usage count. Don't ask me where they get the data. See also here:
http://www.eclipse.org/recommenders/manual/#intelligent-code-completion
To disable the feature go to the preferences page Code Recommenders|Completions and uncheck "Enable intelligent code completion".
Another issue which might negatively affect code completions appears to be 'Java Proposals (Task-Focused)'. For example, it causes map.put() to be replaced with map.compute().
You can disable these from Preferences | Java | Editor | Content Assist | Advanced.
See also: http://literatejava.com/eclipse/bad-auto-completions-in-eclipse/

Is it possible in Eclipse to set longer time to show hints?

I want to know if it's possible to set a longer time to show hints in eclipse?
Eclipse has many hints(tooltips) for suggesting about error corrections or description about classes.
It makes me nervous, when I want to select my code with mouse to copy or doing something else, this ugly hint appears so fast.
This is what i've found:
eclipse hint, maybe it can help you.
You can go to the editor preferences:
Window -> Preferences -> "your language" -> Editor -> Content Assist
and choose how many delay you want

Eclipse content assist auto appends type for variable

I just started to use Juno for a couple of days, the content assist mechanism seems different from what it behaves before.
For example, if I try to declare a variable
Boolean isVisible
The content assist of Juno will give you a drop-down list with the variable name
isVisibleBoolean
as hint.
And the very annoying thing is that no matter what I typed in(; or SPACE), the "isVisibleBoolean" will be selected.
Does anybody know how can I disable the auto-variable-type-appending thing?
Much appreciated.
I'm using Mac OS X 10.8.1 currently, haven't tested it yet in windows.
Based on the discussion for Eclipse Bug 412992, check your Content Assist Auto Activation settings:
Window->Preferences->Java->Editor->Content Assist
If, for example, characters a-z are listed as "Auto activation triggers for Java", you can remove them and the type name will not be auto-appended to a new variable name when you hit ' ' or ';'. It's up to you to determine the best configuration/tradeoffs for your style based on the available options.
It seems that it is not possible.
See answers to Eclipse Bug 378588: https://bugs.eclipse.org/bugs/show_bug.cgi?id=378588
This is still a problem in Eclipse 2018-12 and it only seems to occur if you changed the Auto activation triggers for Java setting to e.g. ._abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ, which'll make the Content Assist (almost) always pop up, even without pressing Ctrl+Space (Windows).
There's a new setting that was added in Eclipse 2018-12 and makes it a bit less annoying (mentioned in the comments below the bug report):
In Window - Preferences - Java - Editor - Content Assist tick the Disable insertion triggers except 'Enter' box.
With this setting enabled, Content Assist is still going to trigger (depending on the other settings) but you have to press Enter to accept a suggestion.
Not a perfect solution:
Window->Preference->Java->Editor->Content Assist->Auto activation Triggers for Java: .ABCDEFGHIJKLMNOPQRSTUVWXYZ
In this way, only classes and types will be popped up for proposals.
Just a suggestion, the choice is up to you.
What you see there is name completion for object types. And this may often make sense, e.g. pressing Ctrl-Space after List book will complete that to List bookList. For primitive types this is not done, so int count will not get any completion when pressing Ctrl-Space. This would be a (not really good) solution to your problem by declaring the variable as primitve boolean.
What I really recommend as solution is to change your style of writing variable declarations. For your example, write isVisible = false instead, have the editor complain about the missing type declaration, hit Ctrl-1 (from wherever your cursor might be placed), Enter.

Javadoc Tooltip with Content Assist in Eclipse

When i started to use Eclipse's Content Assist, Eclipse used to give me Javadoc help of item i focus in a tooltip box next to content assist. However, after a while Javadoc tooltip stopped working. I tried resetting preferences to default but no luck. What should i do?
p.s: Javadoc works when i highlight an element (i.e. a method).
I mingled with various options for 4 hours...even created a new workspace. Finally what worked for me was some preference changes.
Goto Preferences > Java > Editor > Content Assist, click on Restore Defaults.
Restart Eclipse and you are good to go.
You could try checking you have the latest version (and possibly reinstalling) xulrunner. That's Mozilla's platform independent GUI library, and as far as I'm aware it's used to display the javadoc, both content assist popups and in the javadoc tab. The likely cause of your problem is bugs/communication difficulties between eclipse and xulrunner.
I was facing the same problem here, and then, armed with Gaurav Kumar tip, I managed to solve it.
The problem here was that I had put a lower auto activation delay value. When I put it back to 200 and restarted Eclipse, the javadocs came back.
I solved the problem by changing Preferences > Java > Editor > Content Assist -> Auto Activation -> Auto activation triggers for Javadoc from "##" to "#".

Eclipse hang when copying / pasting code

I have a big problem. Eclipse is hanging up when I do any copy/paste with Ctrl+C / Ctrl+V keys.
Is it due to the Eclipse validation code system?
Do I mess something in my Eclipse setting?
Here is my conf :
Eclipse 3.4.2
Plugin RSE
Windows XP pro Service Pack 2
Java VM version = 1.5.0_11-b03
Disabling Hyperlinking fixed this for me. You could also just change the Default modifier key to something other than CTRL if you still want to use hyperlinking.
Go to Window -> Preferences -> General -> Editors -> Text Editors -> Hyperlinking and either uncheck Enable on demand hyperlink style navigation or change Default modifier key.
I had the same issue, and was able to solve it by going to:
Preferences -> Javascript -> Editor -> Typing -> "When pasting" heading
... then turning "Update imports" off.
That one change on its own completely eliminated it, when I was previously getting hangs of 2 seconds or more on almost every copy or paste.
I solved this issue with these steps:
Identify which "editor" is causing the problem. I detected that, in my case, the java script editor was the one causing it, but when copy/pasting in a simple text editor, (no high light, no color , no nothing) there was no such problem.
Note:Eclipse loads the file in different "editor windows/ plugins" depending on the file extension, this is configured in General > Editors > File Associations
As my case was caused by the JavaScript editor, went to Preferences > Java Script > Editor > Typing, and disabled all the "Automatically" boxes. This made the trick.
I solved unchecking all bound to CTRL + C except Copy in Window -> Preferences -> General -> Keys
THE solution!! For me at least.
If CTRL + C works for some editor, not for other, then some plugin settings must have re-affected them to another command.
So you have to go to:
Window->Preferences->General->Startup and Shutdown
and try to disable, one by one the plugins activated on startup:
in my case, was "Dynamic Languages Toolkit Core UI"
I think I have found a beginning of a solution here.
Starting Eclipse with -clean option seems to be better but this not enough.
this is because my "workspace building is hanging up on some flash file"
I faced the problem when editing java code. Every time I typed CTRL + C the editor freezes for a short period of time.
In my case I only turned of the Go to declaration that is available in textual editors. SeeWindow -> Preferences -> General -> Editors -> Text Editors -> Hyperlinking.
In my case it seemed to be related to remote connection to the PC (working directly on the PC was not freezing it, while working remotely via Remmina it was).
My fix was to unbind ALL commands on Ctrl+C (Window > Prefs > General > Keys), including the basic Copy (!!!). The operating system (or Eclipse core functionality) seems to handle clipboard keys correctly by default, no need to bind the additional "Copy" command to it.
Now it's not freezing anymore, enjoy!
Just wanted to share my observations here as a pebble in the ocean, I had tried with all most all of the above options but it didn't solve my issues.
Actually, in my case the main culprit was the java file size, as lines of code increased encountering this hanging while copy & paste actions.
So quick workaround which I made to have a temp file for development and once all done, moving the code to respective java file, get me out of this hurdle. (I am a selenium + Java guy, so this workaround worked for me).