" Use tab for trigger completion with characters ahead and navigate.
" NOTE: There's always complete item selected by default, you may want to enable
" no select by `"suggest.noselect": true` in your configuration file.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1) :
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice.
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm()
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
2条答案
按热度按时间mtb9vblg1#
简短回答
如果您想绑定Tab键以进行自动补全,请将其粘贴到您的.vimrc或init.vim
详细答案
所以,你必须做2插入模式重新Map,在这种情况下,我将我的完成重新Map到Tab键。
观察结果:如果要将其他键绑定到自动完成:
现在,CoC也会用Tab键自动完成,但Enter也是自动完成的,我想绑定Enter,而不是自动完成键。
在VimScript中,Enter表示为
<cr>
观察结果:
nlejzf6q2#
示例vim配置为COC提供了一些非常有用的提示。
但具体到你来说,这是相关的: