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?


You're looking for :h 'scrolloff':

'scrolloff' 'so'    number  (default 0)
    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
  • 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

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.

  • 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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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