I am search for the opposite of winline(). winline() returns the screen line in the window of the current cursor position. I want to be able to set it. Therefore scroll the windows content so that the line the cursor is currently in, lands in screen line x.
vim already provides commands like zz to scroll the current line to the middle of the window or zt to scroll it to the top of the window. But I didn't find a way to scroll it to a specific line.
Edit:
Just for reference: I can calculate it myself by getting the actual winline with winline(), calculating the difference and calling one of:
execute "normal! " . count . "\<C-Y>" execute "normal! " . count . "\<C-E>" But that seems slightyl awkward to me and has the actual drawback that it won't work (and in fact does unpredictable things) if the user remapped <C-Y> or <C-E> to some other operation.
it won't work ... if the user remapped <C-Y> or <C-E>Actually, you are usingnormal!(with the bang), which ignores mappingsztmoves the line with the cursor to the top of the window (while the cursor remains in that line).