0

I'm trying to setup Vim to use ctags to autocomplete struct members when I press C-x C-o, but I get Pattern not found error. I tried both with . and ->. Vim can find tags file because I can jump to definiton using C-].

In my vimrc file I have enabled omnifunc

filetype plugin on

And when I query for omnifunc in my code I get

omnifunc=ccomplete#Complete

I'm aware of OmniCppComplete plugin, but I dont program in C++, I just need this bacis functionality for C.

This is how I generate tags file.

ctags -R --fields=+iaS --c++-kinds=+p --extra=+q --exclude=Library/* --exclude=.git/* --exclude=Plugins/* -h [\".c.cpp.h.cs\"]

I copied some of the extra settings from above mentioned plugin.

This is the sample code I use to test:

struct Test
{
    int member;
} Test;

struct Test test;
test.me // pattern not found

struct Test *test2 = &test;
test2->me // pattern not found

I don't know if I'm missing something obivous, but Vim's help docs for ft-c-omni states this should work out of the box.

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.

Thanks, Vjekoslav

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.