One thing I like about Visual Studio is that you can automatically insert the first choice of the content assist instead of pressing Ctrl+Space and then choose the first option from the menu.
Is there a similar way to map a special key combination to always insert the first choice in Eclipse ?
If such option is not a native option in Eclipse, is there a plugin for that ?
I have seen a similar question in SO : Content assist without choosing in Eclipse but the solution suggested there was to rename the content assist tag that is triggered to something unique, I'm looking for something that works for everything.
Nope auto-insert only works when there is only one choice.
You may open an enhancement request for this feature against JDT/Text - https://bugs.eclipse.org/bugs/enter_bug.cgi?product=JDT
Related
I have a quick question that might save me a few seconds of annoyance every day. I know that eclipse can do a lot of autocomplete magic, so this might be possible:
As a programmer who learned with python, I constantly forget to surround contitions in control structures (like if or while) with parentheses. How do I make eclipse autocomplete opening and closing parentheses when I finish typing while or if?
I am aware that I can autocomplete whole structures with ctrl-space, but how can I configure eclipse to do this by itself?
Any help is appreciated.
So in stock Eclipse, the usual way to bring up assisted content is to type Ctrl+Space. The problem with this is that it brings up both Help Proposals and Template Proposals, with the Help Proposals displayed first. You end up wasting time scrolling down to find what you actually want from the Template Proposals. And there's just that much more clutter to choose from.
The solution is this:
Go Window->Preferences->General->Keys. In the type filter text search for "Template". This should bring up a "C++ Content Assist (Template Proposal)" line. Click on it. Now map this to whatever shortcut you'd like (I did Shift+Space because that's an easy one to do while typing). Make sure to click on the "Binding" option to do this. Click "Ok" and you're done!
If you ever want to add or change what is brought up by that shortcut, and for which specific strings it works, just go Window->Preferences->C/C++->Editor->Templates and you can edit those to do exactly what you'd like when using that newly assigned shortcut.
Hope this helps.
EDIT: I am unable verify if this works for PyDev, as I'm running Eclipse Oxygen, which doesn't currently offer PyDev or the Eclipse Marketplace Client plugin. However, my guess is this would still work in PyDev. Best of luck!
Sources:
Setting auto complete shortcuts in Eclipse
How to change the Control+Space autocomplete shortcut keys in Eclipse for Android
Thanks for any help, but the only thing that seems to work are workarounds. My prefered "solution" is to change the Auto activation triggers for Java in Preferences>Java>Editor>Content Assist from . to .iwfs, so that the autocomplete dialog automatically pops up when I start typing if, while, for or switch. Then hitting enter will do exactly what I needed.
I found an interesting Stackoverflow topic, but it is an old one and I'm afraid people won't be reacting anymore, so I hope it is ok to create a new one.
First of, I am using Netbeans 7.2 and I want to use automatic code completion more. It works nice on methods/classes with the '.' already, but I would like it for the variable names aswell.
So I found this topic: How can I make auto completion in netbeans include both variables as well as methods? , more precisly the accepted answer.
This is what I have always wanted! Except one issue, it decides to automatically insert the name if only one result is available, while I am still typing unaware of that fact.
I have tried disabling Insert Single Proposals Automatically (Tools -> Options -> Editor -> Code Completion), and it does kind of work. But once I type the next letter, it still decides to complete it automatically.
Does anyone know a fix for this or another way to achieve the same?
Regards.
Ah, I found it now: If you want it as I described in the opening post, then set this for Completion Selectors in Java:
[.,;:([+-=] (Note the extra white space on the end, it is important.
Now it will not autocomplete on any character anymore, but still give you the suggestions box.
Go to (Tools -> Options -> Editor -> Code Completion)
Select Language Java
add tick to Auto Popup on Typing Any Java Identifier Part
and you can tick Subword Completion
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.
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!)
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
Go to Window/Preferences/Java/Editor/Content Assist and choose settings that works for you.
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
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.
Is there a way, like some key binding or some settings, to make the content assist to choose the best match one, or the first one, without showing the window? It's always faster when only one choice is available, like
many other IDE has done so.
See this blogpost
Short summary:
Rename the content assist tag that is triggered to something unique (blog author changed "test" to "tst") and change the template to have auto-insert enabled.
When your template is the only choice, it will then be autoinserted.
No. It would require multiple keybindings ala Intellij IDEA, and Eclipse has only notion of "content assist" which is used for autocompletion of everything that could be useful when you invoke it.
Besides, "best match" sounds to me like it would be very annoying, since IDE's best guess might not be your best guess.
How does the Eclipse editor work to enable code completion? For example, within the XML editor for Hibernate property files, if I ctrl-space within a tag, a list of possible value relevant to hibernate will show up.
I understand that the XML editor is pre-configured to understand xml tag, but how about tag specific to a particular framework? How does Eclipse know about that?
I believe that the eclipse XML editor gets the content assist information from any referenced DTDs, or XMLSchema information it associates with the XML file. Try this experiment: Remove the DOCTYPE entry at the beginning of the file and see if content assist still works.
If you're interested in writing your own content assistants, you may want to start by reading the following:
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/editors_contentassist.htm
In a nutshell, like most things in Eclipse, this is a platform hook. When you press the button, it queries all the registered assistants (I'm simplifying here), and they provide suggestions based on the current element or even the current content.
When writing a source editor or viewer for a particular language or document type, it is common to provide at least some rudimentary content assistants.
Removed the DOCTYPE entry at the beginning of the file and im now able to see the commands while typing ctrl+space...
To add to Uri's answer, you can define your own editor for your own language with XText as long as you have a simple EBNF grammar language for your DSL (domain specific language).
You will have:
syntax coloring,
model navigation (F3, etc.),
code completion,
outline view, and
code templates.
Here is a solution you can work. Actually I was facing a same problem with struts.xml file. I was not able to produce tags by cntrl+space
what i did was...
go to Preferences...Java...Editor...Content Assist...Advanced
check all the check-boxes ON and press OK.
sometimes the problem persists due to some false alarming in eclipse. If it happens, just delete your xml file and create a new one in same location.
I hope it will help.
I had the same issue while using the struts.xml file.
I got fix when I tried below...
Go to “Preferences>Java>Editor>Content Assist>Advanced“. Make sure “Java Non Types Proposals” are ticked on both the places as shown in the image below then click Apply and OK button:-