How do I keep 10 lines visible when scrolling up to EOF with CRTL-F?

I am used to using vi, not vim. What I find annoying in vim is that when you are scrolling with CTRL-F and reach EOF, vim scrolls down to the very last line and put this line on the top of your screen, and you can't see the lines above. You must scroll up a little bit so you can see the context. All this happens with CTRL-F only, not with j or the down cursor key.

In vi, you scroll down (with CTRL-F), but when you reach EOF it still show you, say, 15 lines and then the typical ~.

How can I config vim to behave like vi in this case? I am using Putty for remote access.


Solution 1:

You want to set option scrolloff:

'scrolloff' 'so' number (default 0)

number of screen lines to keep above and below the cursor. This will make some context visible around where you are working.

Use e.g.

:set scrolloff=10

to always keep at least 10 lines visible.

Solution 2:

It's easier to get to the bottom of a file with shift-g. It does not go past the end of the file.