In Vim normal mode, you can press ctrl+e and ctrl+y to scroll down and up, respectively. I'm trying to make a key-bind that lets me do this from insert mode as well. This is what I've got:
" Scroll up and down while in insert mode.
inoremap <C-e> <C-o><C-e>
inoremap <C-y> <C-o><C-y>
This works like expected, but it has a big flaw. It leaves insert mode, scrolls, then re-enters insert mode. This is relevant when it comes to undo, repeat command etc. and I would like to be able to scroll up and down without leaving insert mode. Thoughts?
You could take a look at :h i_CTRL-X_CTRL-E
, which is a built-in insert-mode mapping to scroll:
*i_CTRL-X_CTRL-E*
CTRL-X CTRL-E scroll window one line up.
When doing completion look here: |complete_CTRL-E|
*i_CTRL-X_CTRL-Y*
CTRL-X CTRL-Y scroll window one line down.
When doing completion look here: |complete_CTRL-Y|
So in your case, this would probably do the trick:
inoremap <C-e> <C-x><C-e>
inoremap <C-y> <C-x><C-y>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With