0

zz moves current line & cursor at the middle of the screen.
zt moves current line & cursor at the top of the screen.

Is there a way to do the same as zz and zt, but for a quarter (25%) from the screen top?


Here is what I came up with so far:

map <silent> <expr> zT "zt" . (&scroll / 2) . "\<c-y>"

But it does not do exactly what I want, because if there are wrapped lines that take for example 10 visual lines, one stroke of <c-y> will go over those 10 visual lines in one go.

1

I'm not sure if zz and zt have an special treatment that avoid the visual lines you mentioned in your solution. But if they do have you could try resizing the window:

nnoremap <expr> zT 'zzz'.(&scroll).'<CR>Hz'.(&scroll*2).'<CR><C-O>'

Notice that this expects that 'scrolloff' is set to 0. If you use a different value you could write a function to save the original value and restore it at the end.

  • Thanks! Works well for me since I don't use scrolloff. – Jerome Dalbert May 29 '17 at 23:42

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.