vim中的omnicomplete,换档卡舌不工作?
我试图让vim允许我用tab键在自动完成弹出列表中循环。它适用于tab,但不适用于s-tab(shift tab)。 似乎shift tab在应用C-P之前以某种方式取消了自动完成菜单 有人有什么想法吗vim中的omnicomplete,换档卡舌不工作?,vim,omnicomplete,Vim,Omnicomplete,我试图让vim允许我用tab键在自动完成弹出列表中循环。它适用于tab,但不适用于s-tab(shift tab)。 似乎shift tab在应用C-P之前以某种方式取消了自动完成菜单 有人有什么想法吗 function InsertTabWrapper(direction) if pumvisible() if "forward" == a:direction return "\<C-N>" else return "\<C-P&g
function InsertTabWrapper(direction)
if pumvisible()
if "forward" == a:direction
return "\<C-N>"
else
return "\<C-P>"
endif
endif
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-x>\<c-o>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper("forward")<cr>
inoremap <s-tab> <c-r>InsertTabWrapper("backward")<cr>
函数InsertTabWrapper(方向)
如果可见()
如果“前进”==a:方向
返回“\”
其他的
返回“\”
恩迪夫
恩迪夫
设col=col('.')-1
如果!col | | getline('.')[col-1]!~'\k'
返回“\”
其他的
返回“\\”
恩迪夫
端功能
inoremap=InsertTabWrapper(“向前”)
inoremap InsertTabWrapper(“向后”)
对于
映射,您错过了
后面的等号“=”
但是,我建议这样做:
function! InsertTabWrapper()
if pumvisible()
return "\<c-n>"
endif
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-x>\<c-o>"
endif
endfunction
inoremap <expr><tab> InsertTabWrapper()
inoremap <expr><s-tab> pumvisible()?"\<c-p>":"\<c-d>"
函数!InsertTabWrapper()
如果可见()
返回“\”
恩迪夫
设col=col('.')-1
如果!col | | getline('.')[col-1]!~'\k'
返回“\”
其他的
返回“\\”
恩迪夫
端功能
inoremap InsertTabWrapper()
inoremap pumvisible()?“\”:“\”
使用
映射。它更清晰、更清晰(许多人对=
事物一无所知)
像这样映射
,您可以在insertmode中取消登录
似乎有人对你的代码印象深刻:天哪!我在RSS提要上看到了这篇文章,但没有意识到这是我的答案。