Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim autocomplete key bindings for closing & choosing

Tags:

vim

I have j/k set to scroll in the autocomplete box as posted in this question: Scrolling in vim autocomplete box with jk movement keys

Now I want to map h to close the box without completion, and l to close with completion. Both should stay in insert mode. How can I do this?

like image 968
Pubby Avatar asked Jan 24 '26 10:01

Pubby


1 Answers

inoremap <expr> h ((pumvisible())?("\<C-e>"):("h"))        
inoremap <expr> l ((pumvisible())?("\<C-y>"):("l"))
like image 76
Prince Goulash Avatar answered Jan 26 '26 05:01

Prince Goulash



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!