So I have read :help scroll-cursor
and really like zz
, which puts the line your cursor is on in the middle of your window.
I'm looking for help to make a mapping that would perform similar to zz
but puts the line my cursor is on at 20% of the window height (or 25%, 30% etc).
Edit:
Thanks to ZyX and Drasill, I was able to modify his function to get the desired functionality:
function ScrollToPercent(percent)
let movelines=winheight(0)*a:percent/100
if has("float") && type(movelines)==type(0.0)
let movelines=float2nr(movelines)
endif
let oldso=&so
execute ":set so=" . movelines
execute "normal! zt"
execute ":set so=" . oldso
endfunction