I have a file, which contains lines of function name, now I want to use them for code auto completion, and only for file names end with .XXX.

How should I do it, is it possible to work with ctags or Omni plugin?


You can use dictionary completion, i.e.

:setlocal dictionary+=/path/to/your/file

and then trigger the insert-mode completion with <C-x><C-k>; see :help i_CTRL-X_CTRL-K.

If you want this only for filetype xxx, put the :setlocal in ~/.vim/after/ftplugin/xxx.vim.

In contrast, Omni completion gives you more power, but you have to write the completion function yourself. (You could write a function that reads in your file, but why do all the effort when Vim has this built-in?!)

  • That worked after providing an extra au BufRead,BufNewFile *.idc set ft=idc line, but I still prefer OnmiFunc – daisy May 6 '13 at 2:12

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.