1

I move around using the arrows ←↓↑→, never really got used to the hjkl thing. I know I'm supposed to use the hjkl thing.

When hitting ↓, it reaches a point where the caret is on the lower side of the display, until I hit some ↑ hits.

Most of the time I need more context down. How do you move the doc down while not moving the caret?

13260
  • 79
  • 1
  • 11

3 Answers3

6

You're looking for :h 'scrolloff':

'scrolloff' 'so'    number  (default 0)
            global
    Minimal number of screen lines to keep above and below the cursor.

So you can add something like this in your .vimrc:

set scrolloff=10
statox
  • 49,782
  • 19
  • 148
  • 225
  • By not moving the caret I didn't mean leave the caret in the same document line but leave the caret in the same terminal line. In :h scrolling CTRL-D matches, but defaults to half a screen and I need only one line. I read it can be feed a [count], but I didn't understand how to feed it. – 13260 Apr 25 '19 at 10:39
  • 1
    @uprego Oh you mean something like :h 'scrolloff' to always have some lines between the cursor and the border of the window? – statox Apr 25 '19 at 11:43
4

You can also use CTRL-e and CTRL-y to move the view, while not moving the cursor.

At the end of your file, you can use CTRL-e until the last line of the document is at the first line of the page.

padawin
  • 1,333
  • 4
  • 8
  • 2
    I shouldn't have edited my answer but that is what I first suggested to OP but they clarified that it wasn't what they were looking for. Anyway that's still two pretty useful commands. – statox Apr 26 '19 at 14:37
  • Everything in Vim is useful! :) – 13260 Sep 24 '20 at 19:05
1

If you want your cursor at the middle, you can use this mapping:

nnoremap <silent> yoz :let &scrolloff=999-&scrolloff<cr>

This will switch your scrolloff option between the value you set (default is 0) and a very large one. The latter means your cursor stays centred.

Biggybi
  • 2,740
  • 9
  • 29