Question

In Vim we can achieve code completion by either using dictionaries or the current file, to come up with suggestions. But what I'm looking after is to have both.

My vimrc has the following code completion:

"k=uses dictionary, i=uses current and included files, t=tag completion.
set complete-=k
set complete+=k
set dictionary+=/some_path/some_file

Using this i can either use a dictionary, or current file. But what I want is to see both at the same time.

How do I do that?

Was it helpful?

Solution

The default completion (<C-N> / <C-P> in insert mode) uses the sources configured in 'complete'. If this option value contains . and k, both current buffer and the dictionary are considered (you might shortly see messages like Scanning tags... etc. after triggering completion that indicate the current source being searched).

That's the whole purpose of default completion; in contrast, you have to use different completion commands (e.g. <C-X><C-K> for dictionary) to use a single source.


Edit: You need to ensure that the k value actually persists; the ~/.vim/view/ suggests you're restoring a saved view; try clearing those views and removing your existing .viminfo file to override any old persisted values of 'complete'.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top