1

I really like Ctrl-E and Ctrl-Y in normal mode, which expose additional lines at the bottom or top of the screen (respectively) without moving the cursor.

I'd like to do the same thing in insert mode sometimes when I'm writing and want to look at some earlier text a few lines up at the same time.

Ctrl-E and Ctrl-Y in insert mode don't do this (although what they do is actually incredibly interesting and useful, especially while modifying config files or markdown tables—see :h i_CTRL-E), and I don't know what keywords to search for to find what I'm looking for.

I'm aware of Ctrl-O Ctrl-E, and Ctrl-O Ctrl-Y, but those seem kind of unwieldy for regular use.

Is there any shorter keybinding that exists in Vim to do this, without special configuration?

1

The built-in way to scroll while in insert mode is described at :h i_CTRL-X_CTRL-E

                        *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|

After CTRL-X is pressed, each CTRL-E (CTRL-Y) scrolls the window up (down) by
one line unless that would cause the cursor to move from its current position
in the file.  As soon as another key is pressed, CTRL-X mode is exited and
that key is interpreted as in Insert mode.

I particularly like the fact that once you pressed CTRLx you can keep pressing CTRLe or CTRLy without having to press CTRLx again.

1

If you set mouse=a the mouse can also scroll in insert mode.

And the and keys also work in insert mode. But they do not scroll but move the cursor just like the shifted versions.

And with extra configuration you can obviously do

inoremap <C-Up> <C-O><C-E>
inoremap <C-Down> <C-O><C-Y>

Or similar things.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.