Naturally scroll past end of last line in vim

I don't think there is a builtin option for this behaviour, but using some keybindings in your config you can keep the line with the cursor in the middle permanently (except for the top few lines of the file):

set scrolloff=99999

nnoremap <C-U> 11kzz
nnoremap <C-D> 11jzz
nnoremap j jzz
nnoremap k kzz
nnoremap # #zz
nnoremap * *zz
nnoremap n nzz
nnoremap N Nzz
nnoremap gg ggzz
nnoremap G Gzz
nnoremap gj gjzz
nnoremap gk gkzz

This maps common movements to execute zz after and center the screen on the current line. Note that this may lead to flickering on slow terminals (e.g. over ssh), as the screen position actually jumps back before centering again.


You could also move the current cursor line to particular place on the screen.

I use <Ctrl-E> to shift the current line up by one line.

You could also do zt to move the current line to the top of the page.

More info here

Tags:

Vim

Vimrc