【发布时间】:2013-06-11 20:45:39
【问题描述】:
我将 AutoComplPop 与 omnifunc 一起使用。
而不是 Enter 在自动完成弹出窗口中自动完成选择,我想使用 Ctrl+Enter (或其他一些组合)并让 Enter 正常运行。
最后一点很重要:如果我想插入回车并且自动完成弹出窗口突出显示某些内容,我必须按两次 Enter。
那么:如何重新映射自动完成键?
【问题讨论】:
标签: vim autocomplete
我将 AutoComplPop 与 omnifunc 一起使用。
而不是 Enter 在自动完成弹出窗口中自动完成选择,我想使用 Ctrl+Enter (或其他一些组合)并让 Enter 正常运行。
最后一点很重要:如果我想插入回车并且自动完成弹出窗口突出显示某些内容,我必须按两次 Enter。
那么:如何重新映射自动完成键?
【问题讨论】:
标签: vim autocomplete
我不认为 AutoComplPop 插件对 Enter 键有任何作用;相反,这是完成弹出窗口可见时的默认行为。见:h popupmenu-keys:
The behavior of the <Enter> key depends on the state you are in: first state: Use the text as it is and insert a line break. second state: Insert the currently selected match. third state: Use the text as it is and insert a line break.
只是 AutoComplPop 默认选择第一个匹配项(内置完成不这样做)。
回答你的问题(虽然我不完全明白你想要什么行为):
弹出菜单没有特殊模式,您必须使用:help map-expr 并使用pumvisible() 检查弹出菜单。例如,要使<Enter> 中止完成并插入换行符:
:inoremap <expr> <CR> pumvisible() ? '<C-e><CR>' : '<CR>'
【讨论】: