Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between the ‘omnifunc’ and ‘completefunc’ autocomplete in Vim, except for the invocation key mapping?

Tags:

Is there any difference in functionality between these two types of complete-functions in Vimscript?

like image 846
dan Avatar asked Aug 04 '11 12:08

dan


People also ask

What is Omnifunc Vim?

vim-text-omnicompleteThis plugin automatically sets the omni completion function ( omnifunc ) for files with the text filetype. As such, when editing text files, you will be able to use Ctrl x Ctrl o to show a list of autocomplete suggestions.


1 Answers

Technically, there is no difference in implementation of both User-defined completion (see :help compl-function, :help 'completefunc') and Omni completion (see :help compl-omni, :help 'omnifunc'). Both of them work by calling a function of a special semantics that locates the start of the expression to be completed at the current position, and provides appropriate completion suggestions (see :help complete-functions).

Where the difference between these two types of completion manifests itself, is the purpose of completion. User-defined completion should be customized by the user themselves according to conditions specific to a particular completion idea. Omni completion is supposed to be filetype-specific. Hence, separate Omni completion functions for different filetypes are loaded automatically by Vim from autoload/‹ft›complete.vim files, where ‹ft› stands for a particular filetype. See those Omni completion files for C or Python filetypes as a reference.

like image 113
ib. Avatar answered Sep 30 '22 07:09

ib.