开发者

Scrolling in vim autocomplete box with jk movement keys

开发者 https://www.devze.com 2023-02-05 19:47 出处:网络
In vim you can start typing a word, hit ctrl-n, and a box will popup with suggested completions. I don\'t like having to move my 开发者_开发知识库hands away to the arrow keys to scroll through this li

In vim you can start typing a word, hit ctrl-n, and a box will popup with suggested completions. I don't like having to move my 开发者_开发知识库hands away to the arrow keys to scroll through this list. Is there some way I can use the jk keys to scroll down/up instead?


I know the question is asking to use the J and K keys but you can also avoid using the arrow keys another way.

After hitting ctrl+n to get the autocomplete popup, you can navigate the list with ctrl+n and ctrl+p.


inoremap <expr> j ((pumvisible())?("\<C-n>"):("j"))
inoremap <expr> k ((pumvisible())?("\<C-p>"):("k"))


inoremap <expr> <down> ((pumvisible())?("\<C-n>"):("\<down>"))
inoremap <expr> <up> ((pumvisible())?("\<C-p>"):("\<up>"))
0

精彩评论

暂无评论...
验证码 换一张
取 消