我正在尝试将自动完成键从“Enter”键重新映射到“TAB”,因为当我打算转到下一行时,我一直在自动完成。下面的代码是 coc 的默认选项,我认为这是我应该能够重新映射密钥的地方。
" 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>"
我认为将开头的 <cr> 更改为 <TAB> 会起作用。然而,虽然它允许我使用 TAB 自动完成,但在某些情况下它会创建奇怪的自动缩进。例如:
//normal behavior
someFunction(){
//cursor here appropriately indented
}
//behavior after I made the changes mentioned above
someFunction(){
//cursor here}
我想我只是根本不了解有关 coc 或在 VIM 中重新映射键的内容。
为什么我不能简单地将 <cr> 更改为 <TAB>?如何将自动完成键从“Enter”重新映射到“TAB”?