As title. For example, say I imagine there is something like scrolloffTop
and scrolloffBottom
and I can set each with different values. If there is no such options, I would like to know is it possible to achieve this by script.
1 Answer
Here's a script that will set a different scrolloff
value when the cursor is in the top or bottom half of the window (12 and 0 respectively in the example).
It uses the CursorMoved
event, which will trigger quite often. This might not be the best approach.
augroup switchScrolloffTopBottom
autocmd!
autocmd CursorMoved * if winline() < &lines/2
\| setlocal scrolloff=12
\|else
\| setlocal scrolloff=0
\|endif
augroup END
-
2I'm willing to burn my CPU to have this feature. Thanks a lot! Commented Dec 16, 2021 at 7:56
scrolloff
is what there is.