19

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.

Mark Henderson
  • 68,316
  • 31
  • 175
  • 255
Gaston
  • 193
  • 1
  • 5

2 Answers2

30

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.

sleske
  • 9,851
  • 4
  • 33
  • 44
  • I could not remember the name of this option but could remember the name of a related `--jump-targets=n` option from `less` when dealing with scroll behavior through search results with `n` and `N` keybinds. I searched for something like `vim equivalent of less "--jump-targets"`. Hopefully this will help others find their way. – pkfm Oct 14 '20 at 03:16
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.

James T
  • 545
  • 1
  • 4
  • 9
  • 3
    His goal is not to try and go to the end of the file. He's scrolling through the file with CTRL-F and doesn't like Vim's behavior when the end is reached. That's a different thing. – Starfish Jan 07 '12 at 02:56
  • @Starfish Ah ok. My misunderstanding. – James T Jan 07 '12 at 07:20