I am trying to remap the autocomplete key from the "Enter" key to "TAB" because I keep autocompleting when I intend to go to the next line. The code below is the default option for coc, and I think this is where I should be able to remap the key.
" make <CR> auto-select the first completion item and notify coc.nvim to
" format on enter, <cr> could be remapped by other vim plugin
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
\: "\<c-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
I thought that changing the in the beginning to would work. However, although it does allow me to autocomplete using TAB, it creates weird auto indentations in some cases. For example:
//normal behavior
someFunction(){
//cursor here appropriately indented
}
//behavior after I made the changes mentioned above
someFunction(){
//cursor here}
I assume I just fundamentally don't understand something about coc or remapping keys in VIM.
Why can't I simply change that to ? How can I go about remapping the autocomplete key from "Enter" to "TAB"?
2条答案
按热度按时间djmepvbi1#
我不太了解vimscript,但我通过反复试验成功地让一些东西工作起来。
默认设置:
在选项卡上自动完成:
nwsw7zdq2#
替换示例coc config中的以下行
与此:
这是基于@christofuy的回答,但在此行更改后更新。