When turning pages (scrolling) in vim, the default cursor moves up to the top of the screen or down to the bottom of the screen. I hope to keep the position on the screen unchanged, that is, only move the text, but not the cursor (relative to screen) position.
How to achieve this? Please advise, thanks in advance!
漂亮男人2017-05-16 16:38:15
You mean these?
ctrl + y goes up one line
ctrl + e goes down one line
ctrl + u goes up half the screen
ctrl + d goes down half the screen
ctrl + b goes up one screen
ctrl + f goes down the screen
You can check out this stackoverflow answer
http://stackoverflow.com/questions/3458689/how-to-move-screen-without-moving-cursor-in-vim
The ToggleScrollMode function below is good, I guess it should meet your needs
PHP中文网2017-05-16 16:38:15
If you cannot install the plug-in, you can try to turn on the relative line number display of vim, and jump quickly based on the relative line number after turning the page.
大家讲道理2017-05-16 16:38:15
Added to
.vimrc
" 在上下移动光标时,光标的上方或下方至少会保留显示的行数
set scrolloff=7
This 7 you set yourself
淡淡烟草味2017-05-16 16:38:15
You can zz to align the line to the center after scrolling, similar to emacs' <C-l>
迷茫2017-05-16 16:38:15
ctrl-d scrolls down half the screen, the cursor will not move
ctrl-f Scroll down one screen and the monogram will move.
shift-m moves the cursor to the middle of the screen and can be used after ctrl-f to flip the screen