I'm sure you've seen the VIM documentation (:help ft-c-omni
) for this:
When using CTRL-X CTRL-O after a name without any "." or "->" it is completed
from the tags file directly. This works for any identifier, also function
names. If you want to complete a local variable name, which does not appear
in the tags file, use CTRL-P instead.
When using CTRL-X CTRL-O after something that has "." or "->" Vim will attempt
to recognize the type of the variable and figure out what members it has.
This means only members valid for the variable will be listed.
When a member name already was complete, CTRL-X CTRL-O will add a "." or
"->" for composite types.
If I read that correctly, the built-in functionality will, at best, only allow you to use CTRL-P and match the local variables names thus bypassing the TAGS file altogether.
What you really want is a TAGS file that is specific to the translation unit that you're currently working on (header/cpp file). Here are the steps that I would perform if I were trying to solve this problem:
- Create a script (or better yet, incorporate into a makefile) the automatic creation of translation unit specific TAG files.
- Create a command in vim that unloads existing TAGS files, reloads the file specific TAGS file, and performs regular
CTRL-X CTRL-O
omni-completion. If necessary, revert to the original TAGS.
Also, it seems to me like you would want to be able to call the script for #1 directly from VIM since you would be frequently changing the current translation unit as you code.
I hope that gets you started in the right direction, and I'd be happy to see / help you with an implementation =).