In Vim, I don't like how when you reach end of file it puts the last line at the bottom of the screen.

Is there anyway to make the last line be something like 10 lines above the bottom of the screen and just make blank lines under it?

  • 2
    When your cursor reach the last line of the file, if you hit zz it will redraw the screen and position the current line at the center of the window which should display a few ~ lines after EOF. May 9, 2016 at 16:49
  • yes, but if you move the cursor again positioning it at the bottom again. May 9, 2016 at 18:00
  • 3
    It sounds like you have the scrolloff option set. Try :set scrolloff=0 and that behavior should change.
    – Tumbler41
    May 9, 2016 at 18:02
  • 1
    You can read your answer here: stackoverflow.com/questions/7406814/… There are more answers to this, basically it is not possible, only with workarounds.
    – mike
    May 9, 2016 at 19:29
  • 2
    Does this answer your question? Keep X-rows below current cursor position if fewer than Y-rows are left
    – Rich
    Oct 30, 2022 at 21:42

2 Answers 2


You can use ctrlE to scroll down your file, when you are at the end of the file it will add "virtual" line so the last line of the file is not at the bottom of the windows.

Additionally you can use the option scrolloff to always let some lines after your cursor, add this to your .vimrc:

set scrolloff=10

For more details see :h 'scrolloff' and :h CTRL-E.

  • 5
    Unfortunately, setting scrolloff to 10 will still not show lines AFTER EOF like OP wanted.
    – Tumbler41
    May 9, 2016 at 19:17
  • Indeed, that's why I suggested using CTRL-E and ̀scrolloff was just "additional". Now it is a partial solution, OP is free not to accept it since it doesn't completely answer the question.
    – statox
    May 9, 2016 at 20:03
  • 2
    Although it is just a partial solution i think CTRL-E is what i was looking for. I'd love if there was a way to display the lines after EOF automatically though. May 10, 2016 at 17:29
  • @Miguel I'm glad it fits your needs. I think it could be possible to create a mapping which would call <C-e> when you scroll down but I'm really not sure it would work correctly... I'll try and see what is possible to do but I'm not sure I'll be able to create something convenient.
    – statox
    May 10, 2016 at 17:36

In your config you can add zz to j and k. It has the major side effect of centering your cursor. I don't mind and much prefer it to craning my neck. I tried scrolloff and CTRL-E is just uncomfortable to me.

Type the following in : or .vimrc

nnoremap j jzz

nnoremap k kzz

Sourced: http://vim.wikia.com/wiki/Keep_your_cursor_centered_vertically_on_the_screen

  • When using @carlos-vigil tips, you might want to add nnoremap G Gzz to keep consistent behavior when navigating to end of the file with G.
    – jhoffman
    Feb 3, 2022 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.