If you try scrolling when you are at the bottom vim assumes you want to move the text up.
You can replace commands like ctrl-f
with an additional "move cursor to bottom of screen" using zb
. This modification would need to be added to any other commands you wish this to not occur.
:nnoremap <c-f> <c-f>zb
Now when you ctrl-f
at the bottom of the screen it stays at the bottom, but so does every instance of ctrl-f
.
Update
If you would like to do it conditionally you'll need to write a little function that compares your current position to the end of the file.
function! NoScrollAtEOF()
let curpos = getpos('.')
let lnum = get(curpos, 1, -1)
let len = line('$')
if lnum + winheight(0) >= len
normal! zb
endif
endfunction
nnoremap <c-f> <c-f>:call NoScrollAtEOF()<cr>
This function pulls the current position and the end of file position and calls zb
if the current position plus the height of your window is greater than the end of file...if you can see the end of the file in your window.
G
, followed byctrl-f
. I think this is what he is talking about.