Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim autocomplete a struct in C

I'm trying to use Vim autocomplete. I've got a struct in file def.h:

typedef struct test{
        int x;
        int y;
}*test_p,test_t;

And in the corresponding C file:

test_p t;
t->[autocomplete here]

What i should press to fill it with x or y? Neither CTRLP nor CTRLN give me variables from inside test.

I've already used ctags and of course I've included def.h. Here is what is in my tags file:

test    def.h   /^typedef struct test{$/;"      s
test_p  def.h   /^}*test_p,test_t;$/;"  t       typeref:struct:test
test_t  def.h   /^}*test_p,test_t;$/;"  t       typeref:struct:test
x       def.h   /^      int x;$/;"      m       struct:test
y       def.h   /^      int y;$/;"      m       struct:test
like image 693
JosipBros Avatar asked Nov 23 '09 22:11

JosipBros


1 Answers

You are looking for omni-complete (Ctrl-X Ctrl-O).

Ctrl-P or Ctrl-N only autocomplete words from current files/buffers. You want intelisense (R) (omnicomplete) introduced in vim 7 I believe. See C++ code completion - not sure if that helps.

like image 81
stefanB Avatar answered Sep 28 '22 07:09

stefanB