I'm a Java developer and I've downloaded the Eclipse for C (course purposes) and to my amazement the control+space shortcut (for autocomplete) did not work.
I've created a new project and a new class using the wizzards and started to type "print" and then tried to find an autocomplete feature.
After a bit of googling I arrived at C/C++
->Editor
->Content Assist
->Advanced
and there I verified that Help proposals
,Parsing-based proposals
and Template proposals
options were checked.
I then went over to the Keys
preferences page using the link at that page and entered a binding for all relevant content assist from before C\C++ Content Assist (type...)
and chose in the When
box the C\C++ Editor
option.
But alas no autocompletion was offered.
Can someone please point me to the right direction?
UPDATE: I'm accepting the answer not because I'm sure it's right but because I've realised I've made some mistakes with the configuration of the eclipse and have seen that with another installation/开发者_开发知识库configuration (i.e. a friend of mines) eclipse does auto complete, even if it still lack many of the java version features.
Use the Advanced panel in the Preferences window to configure the behavior of the Content Assist (Ctrl+Space) command.
Go to Preferences->C/C++->Editor->Content Assist->Advanced.
Check the parsing-based-Proposals in Default Proposal kinds.
Although the eclipse doesn't provide perfect auto-complete, but it works.. This sometimes happens when you have the indexer turned off.
Try to enable the indexer and rebuild the index.
See this question in CDT FAQ. It contains info about how to find indexer error which might prevent auto-complete.
I'm no Eclipse expert (and I don't even play one on TV), but it might be that it only autocompletes function names that are declared in the current scope - have you added #include <stdio.h>
to the top of your source file to get the declarations for the standard I/O functions?
You should verify that you have the gcc home (i.e. C:\MinGW-4.4.1\bin) defined in the path environment variable (if you're using windows and if not then it's equivelant). Also verify that the file has a .c suffix and that the indexer is on as yousf said.
I think, not sure, that you need to then run eclipse with the -clean flag and the autocomplete will work.
Ittai
i answered it here: Eclipse: How to add include path to be used by autocompletion
You have to explicitly tell it where to find the header:
⇒ Right click on your project
⇒ go to 'C/C++ Include Paths and Symbols'
⇒ select 'Add External Include Path...'
⇒ browse to the location of your header files
⇒ refresh
Maybe it is related with KeyAssist bindings.
If you have tried with content assist:
Enter into Window > Preferences. Menu "General" -> "Keys"
Inside search for "Template" and set:
Key Binding to -> "Ctrl + Space"
When: "Editing Test"
Image helper Image Menu Key Assist Code Complete
Vim offers this functionality by scanning your #include's (the shortcut is Ctrl-N, or Ctrl-P to search backwards). If you can't find any better solution, one last resort could be looking into eclim, which integrates vim features into Eclipse (or vice-versa), and that's sure to offer this feature.
精彩评论