Vim auto complete, both with current file and dictionary

点点圈 提交于 2019-12-08 08:35:05

问题


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?


回答1:


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'.



来源:https://stackoverflow.com/questions/20887628/vim-auto-complete-both-with-current-file-and-dictionary

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!