Vim自动完成,带有当前文件和字典 [英] Vim auto complete, both with current file and dictionary

查看:184
本文介绍了Vim自动完成,带有当前文件和字典的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Vim中,我们可以使用字典或当前文件来完成代码,以提出建议. 但是我要照顾的是两者兼有.

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.

我的vimrc具有以下代码完成:

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.

我该怎么做?

推荐答案

默认完成(在插入模式下为<C-N>/<C-P>)使用在'complete'中配置的源.如果此选项值包含.k,则同时考虑当前缓冲区和字典(触发完成后,您可能会很快看到诸如Scanning tags...之类的消息,指示正在搜索当前源).

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

这就是默认完成的全部目的;相比之下,您必须使用不同的完成命令(例如<C-X><C-K>用于字典)才能使用单个源.

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.

编辑:您需要确保k值确实存在. ~/.vim/view/表示您正在还原保存的视图;尝试清除这些视图并删除现有的.viminfo文件以覆盖'complete'的所有旧持久值.

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

这篇关于Vim自动完成,带有当前文件和字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆