for example when I am typing int main() it would be nice if I could just hit tab and get the list of keywords (auto completion) I want. How can I do this in Emacs?
Asked
Active
Viewed 744 times
1
-
Emacs is too cool for autocomplete :P I use emacs for the reason that it doesnt have autocomplete by default. That way you learn the code better :) just my two e-cents – Jesus Ramos Jul 24 '11 at 03:32
-
@Jesus: that is true but my friend is saying emacs is uncool because it doesn't have it. So I am trying to convince him that emacs can do anything :) – Mark Jul 24 '11 at 03:33
-
It can, if you want I can refer you to an autocomplete that only works with the stuff in any open buffer (not really language specific stuff) I use it on large projects so I don't misspell things sometimes. – Jesus Ramos Jul 24 '11 at 03:34
-
@Jesus: Have you tried "company"? Does that offer language specific auto-completion? – Mark Jul 24 '11 at 03:38
-
Sorry not familiar with that. I tend to avoid autocomplete altogether :) who needs an IDE to code – Jesus Ramos Jul 24 '11 at 03:39
-
@Mark never used "company" mode. I use yasnippet and auto-completion mode for auto complete the coede – kindahero Jul 24 '11 at 04:15
4 Answers
5
You can autocomplete with M-/
. There are also other autocomplete packages available.
-
1`M-/` is bound to `dabbrev-expand` by default. Many people rebind this key to the more comprehensive `hippie-expand` (which incorporates the dabbrev expansion options amongst others). – phils Jul 24 '11 at 05:09
-
FWIW, I also wrote the following answer recently which generates all the `hippie-expand` completions and uses `ido-completing-read` to let the user select the one they want from the minibuffer: http://stackoverflow.com/questions/6515009/how-to-configure-emacs-to-have-it-complete-the-path-automatically-like-vim/6556788#6556788 – phils Jul 24 '11 at 05:16
3
You need CEDET, it contains many good tools that can be used to make EMACS have many features that you would see in a more modern IDE.

Leif Andersen
- 21,580
- 20
- 67
- 100
-
-
Thanks for telling me about CEDET I am think I am going to be alot more productive from now on. – Mark Jul 24 '11 at 05:30
1
You may use yasnippet. By writing 'main' and then TAB, you get
int main (int argc, char *argv[])
{
return 0;
}
(This is not really auto completion.)

mkcs
- 83
- 5
-
-
Does yashnippet do more than just autocomplete the main? How could I extend it to do more? could you show more examples? – Mark Jul 24 '11 at 04:46
-
The package comes bundled with lots of snippet expansions, e.g., 'if' + TAB gives you an 'if' with parentheses, braces for the block, and point inside the parentheses; writing the condition and pressing TAB puts the point inside the braces. You may also create your own snippets; it is pretty simple (no elisp required), see [this](http://yasnippet.googlecode.com/svn/trunk/doc/snippet-development.html) – mkcs Jul 24 '11 at 04:54
1
Asher's answer with the list is probably the best but if you want something that gives you a drop down of possible (non semantic) completions which you can select, you can use auto complete mode.

Noufal Ibrahim
- 71,383
- 13
- 135
- 169