You can keep the cursor line in the middle of the screen and then have the text scroll underneath it by setting the scrolloff to a very large number. Ex:
:let &scrolloff = 999
To read more about how this works:
:help scrolloff
I love this feature and use it all the time but I would like the ability to keep the cursor at other locations other than the middle of the screen. For instance I would like the ability to keep the cursor at the top of the window and have the file scroll underneath it. I am pretty sure there is nothing natively available in vim to do this so I was wondering if anyone had come up with a light wieght vim script snippet to do this (or can someone come up with such a script)?
Here is my little .vimrc helper code to swich the position of the cursor quickly:
" SCROLLFIX SHORTCUTS
function! ToggleMyScrollFix()
if ( g:scrollfix == 5 )
let g:scrollfix = 50
elseif ( g:scrollfix == 50 )
let g:scrollfix = 95
elseif ( g:scrollfix == 95 )
let g:scrollfix = 5
else
let g:scrollfix = 50
endif
endfunction
nnoremap <silent> zz :call ToggleMyScrollFix()<CR>lh
You can make Vim scroll the text using the shifted up/down arrows by mapping Shift-Up to Ctrl-Y and Shift-Down to Ctrl-E. Shift-Down will then scroll down (like moving a scroll-bar down, or like moving a cursor at the bottom of a window down), and Shift-Up will then scroll up (like moving a scroll-bar up, etc).
Press the ESC key to change normal mode. Press the CTRL+f key in order to page down or move forward.
Check out the scrollfix plugin. I used it a couple years ago, so I don't know if it'll still work with the latest snapshots of Vim -- but at worst, it should give you a pretty good start at modifying it to work for you.
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