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
    There are no such options, AFAIK; scrolloff is what there is.
    – D. Ben Knoble
    Dec 15 '21 at 13:51
  • So sad. I need these option...
    – job_start
    Dec 15 '21 at 14:44

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 CursorMoved * if winline() < &lines/2
        \| setlocal scrolloff=12
        \| setlocal scrolloff=0 
augroup END
  • 2
    I'm willing to burn my CPU to have this feature. Thanks a lot!
    – job_start
    Dec 16 '21 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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