When vim turns pages (scrolls), how to keep the cursor position in the screen fixed?

  question, vim

When vim turns pages (scrolls), the default cursor will move up to the top of the screen or down to the bottom of the screen. I hope to keep the position in the screen unchanged, that is, to move only the text but not the cursor (relative to the screen).

How should this be achieved? Ask for advice, thank you first!

You mean these?

Ctrl+y up one line
Ctrl+e next line
Ctrl+u up half screen
Ctrl+d down half screen
Ctrl+b up one screen
Ctrl+f to next screen

You can look at this stackoverflow answer.


The following ToggleScrollMode function is good, I guess it should meet your needs.