How to page move while keeping cursor centered?

In an attempt to Taking back control of hjkl with modifiers keys :

  • How can I jump the cursor half buffer (up/down) and at the same time center the view v-v? (kind of a calculated <#>gvv?)

I can use scrolloff 30,30 - that’s good enough — actually even better than expected.

  • But: can I make the hight dynamic, e.g. floor( (bufferheigth - 5) / 2 )?

Something like this should work, subject to potential off-by-one issues (haven’t tested it thoroughly):

hook global WinResize .* %{
    set-option window scrolloff %sh{
        echo $(( (kak_window_height - 5) / 2 )),30

This works so cool! Thank you :partying_face:

  • I settlet on a 15 offset
  • this allows a range for mouse selection
  • mouse selection doesn’t work in scrolloff areas
  • Still works great on a 1/4 of a screen

No problem, you might want to add a similar hook for the WinDisplay event so that it runs on window creation and after switching from other buffers.