I put in my ~/.vimrc file the next lines of code:
filetype plugin on
set omnifunc=syntaxcomplete#Complete
but nothing happened, when I created a file with .c extension and I pressed <Ctrl-X><Ctrl-O>
the vim editor popped up a "pattern not found" message.
Here one can see my .vimrc:
You have two problems.
The command filetype plugin indent on
tells Vim to:
Those things happen automatically, as you load a new buffer. In this specific case (and others) the C ftplugin contains this line:
setlocal ofu=ccomplete#Complete
which effectively overrides your:
set omnifunc=syntaxcomplete#Complete
There are several ways to solve this problem but the most sensible is to make your own filetype plugin:
Create ~/.vim/after/ftplugin/c.vim
.
Add setlocal omnifunc=syntaxcomplete#Complete
to it.
See :help filetype-plugin
.
As explained under :help ft-syntax-omni
, syntaxcomplete#Complete
pulls its suggestions from the current syntax definition. Since syntax highlighting is not enabled by default and you don't enable it explicitly, there is no "current syntax" and thus no syntax-based completion.
You are supposed to enable it explicitly, in your vimrc
:
syntax on
This is how your vimrc
should look like:
filetype plugin indent on
syntax on
And this is your brand new custom filetype plugin for C:
" ~/.vim/after/ftplugin/c.vim
setlocal omnifunc=syntaxcomplete#Complete