3

I just installed omnicomplete plugin, does it support header auto completion?

When I typed #include <, is it possible to provide a list of header files to complete?

Many thanks!

ib.
  • 25,324
  • 10
  • 71
  • 97
daisy
  • 19,459
  • 24
  • 111
  • 218

1 Answers1

1

You can just use the vim autocomplete feature, which was introduced in vim7.

Just type in first few characters and press Ctrl->P(for backward search) or Ctrl->N(for forward search), vim lists down all options available or completes it.

And Yes it works even for header files.

To make this work you should install ctags In usr/include add:

ctags -f ~/.vim/stdtags -R --c++-kinds=+p --fields=+iaS --extra=+q . 

Add this to your .vimrc

    set nocp
    filetype plugin on
    map <C-L> :!ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .<CR><CR>

    set tags=~/.vim/stdtags,tags,.tags,../tags

    autocmd InsertLeave * if pumvisible() == 0|pclose|endif
Alok Save
  • 190,255
  • 43
  • 403
  • 518
  • Do you have a plug-in for that ? I have Vim 7.3 under Ubuntu, no special plugin, and when I type `#include – J.N. Jun 29 '11 at 04:46
  • 1
    i think ^P ^N only search for strings already present in the file , i'm on 7.3.219 in Gentoo – daisy Jun 29 '11 at 05:49
  • @warl0ck. Actually `` will search all the open buffers and then some (f.ex. included files) for keywords. You can control its scope by settings. – mike3996 Jun 29 '11 at 07:14
  • @progo , i think i understood how vim works , if i type in #include < , with no extra strings , it won't complete for all the headers , but for everything , am i right on this part ? – daisy Jun 30 '11 at 01:01
  • @warl0ck, sure thing. Everything it sees as a keyword. But it won't limit its search to the current buffer (there's `` for that). – mike3996 Jun 30 '11 at 07:46