简体   繁体   English

如何合并vim的完成候选人?

[英]How to merge completion candidates for vim?

I often rely on omni-completion to edit source codes, so my current .vimrc contains following setting to gain quick access to intended candidates: 我经常依靠omni-completion来编辑源代码,因此我当前的.vimrc包含以下设置,可以快速访问预期的候选对象:

inoremap <C-f> <C-x><C-o>

Now I find there are many kinds of ins-completion s except for omni-completion and become interested to use both tags and file names completions too. 现在,我发现除了omni-completion以外,还有许多种ins-completion ,并且也对同时使用tagsfile names omni-completion很感兴趣。

1. Whole lines                                          i_CTRL-X_CTRL-L
2. keywords in the current file                         i_CTRL-X_CTRL-N
3. keywords in 'dictionary'                             i_CTRL-X_CTRL-K
4. keywords in 'thesaurus', thesaurus-style             i_CTRL-X_CTRL-T
5. keywords in the current and included files           i_CTRL-X_CTRL-I
6. tags                                                 i_CTRL-X_CTRL-]
7. file names                                           i_CTRL-X_CTRL-F
8. definitions or macros                                i_CTRL-X_CTRL-D
9. Vim command-line                                     i_CTRL-X_CTRL-V
10. User defined completion                             i_CTRL-X_CTRL-U
11. omni completion                                     i_CTRL-X_CTRL-O
12. Spelling suggestions                                i_CTRL-X_s
13. keywords in 'complete'                              i_CTRL-N*emphasized text*

The question is, how can I list up whole candidates from these specific completion sources on a ins-complete-menu with single command, <Cf> . 问题是,如何使用单个命令<Cf>ins-complete-menu上从这些特定的完成源中列出整个候选人。

You should check the plugin neocomplcache . 您应该检查插件neocomplcache It can acomplish this but the setting may not be trivial. 它可以完成此操作,但设置可能并不简单。

Use the default completion (CTRL-N / CTRL-P); 使用默认补全(CTRL-N / CTRL-P); its completion sources can be configured via the 'complete' option. 可以通过'complete'选项配置其完成源。 Unfortunately, from your list, only tags (not file names) can be (and is by default) included in there. 不幸的是,在您的列表中,只能(默认情况下)包含标签(而非文件名)。 (But don't you know beforehand that you want file completion? I particularly like the many different completion commands because they narrow down the result list, which for me is far more valuable than not having to think about which completion to invoke.) (但是您事先不知道想要文件完成吗?我特别喜欢许多不同的完成命令,因为它们缩小了结果列表的范围,对我而言,这比不必考虑要调用哪个完成功能更有价值。)

If you really want an all-encompassing completion, you'd have to implement that yourself as a user-completion, and you'd have to re-implement all the built-in sources, as there currently is no way to programmatically get them. 如果您确实想要一个无所不包的完成,则必须将其自己实现为用户完成,并且必须重新实现所有内置源,因为当前无法以编程方式获取它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM