0

I am new to vim and I am trying to set it up for use with C/C++. After reading about possible plugins for autocompletion I decided to try clang_complete. I installed it and made sure it is working by using the included example file.

Completion after typing ::, -> or . works, but I just can't figure out how to get a autocompletion menu for local variables and functions defined in the same file or included via header.

Example:

void foobar();

void main()
{
    foobar();
}

When typing foo in main(), would expect clang_complete to be able to complete it to foobar. Did I miss anything when reading the clang_complete documentation or is this really not possible?

Benjamin Sullivan
  • 1,466
  • 1
  • 12
  • 15
worblehat
  • 3
  • 3
  • It has been a while since I last tried it, but afaik it only completes automatically on certain points like `::` or `.` or `->` and for everything else you have to hit something (maybe tab when supertab is active, or ctrl-x p or so, the manual should tell) – PlasmaHH Feb 26 '13 at 15:17
  • 3
    You could use ``. – romainl Feb 26 '13 at 15:19
  • For automatic completion, you can try the [AutoComplPop - Automatically opens popup menu](http://www.vim.org/scripts/script.php?script_id=1879) plugin; I don't know if it works with clang_complete, though. – Ingo Karkat Feb 26 '13 at 16:17
  • You need to press `` after typing in `foo` to activate user completion. – xaizek Feb 26 '13 at 20:58
  • 1
    Sorry, this is not really related to your question, but you should check out the YouCompleteMe Plugin http://valloric.github.com/YouCompleteMe/ It's a bit hard to set up, but it's a lot faster than clang_complete. – guini Feb 27 '13 at 09:21
  • Thanks for all your suggestions! `` and `` is almost what I was looking for, except that it is not really 'context-aware' (scope, privateness,...). The `` shortcut by clang_complete actually provides this functionality, so I will use this most of the time. There is only one drawback with it: It can't complete the name of a variable whose datatype is defined in a header that is not found by clang. In this case I have to use `` to be able to autocomplete the variable name. – worblehat Feb 27 '13 at 12:38
  • @guini: I considered to use YouCompleteMe, but because of the complex set up procedure I decided against it. I use my vim installation on different machines, so installation should be as easy as possible and I like leightweight plugins. – worblehat Feb 27 '13 at 18:32

1 Answers1

0

The answer to the question "how to open the autocompletion menu" is to click < C-x > < C-u > (which means firstly press ctrl and x at the same time, then ctrl and u). Then you'll se a menu of user defined auto completions which is where clang_complete's completions are. If you're as lazy as me and you want the completions to popUp automatically, install an additional plugin like AutoComplPop. You can also switch to YouCompleteMe, which I don't like but may suit you needs better.

Misty
  • 416
  • 3
  • 8