3

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.

2
  • 2
    There are no such options, AFAIK; scrolloff is what there is.
    – D. Ben Knoble
    Commented Dec 15, 2021 at 13:51
  • So sad. I need these option... Commented Dec 15, 2021 at 14:44

1 Answer 1

4

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
1
  • 2
    I'm willing to burn my CPU to have this feature. Thanks a lot! Commented Dec 16, 2021 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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