With set wrap, is there any way to not show the whole logical line when scrolling after the last line or before the first with gj and gk, but only the visual line?

The goal is to prevent jerky movements when 'scrolling', especially when dealing with very long lines (prose) or narrow splits.

Basically, I'd like my cursor to stay on the same line when scrolling, which should be the bottom most line when 'scrolloff' is set to zero when scrolling down (or the top most when going up).

I know this is not the intended behavior of Vim, but I think some kind of script could do the trick. No answer on the internet seems to provide this, though, and I'm not sure how I could achieve this (my knowledge of vimscript is basic to say the least).

I tried set tw=winwidth(0) but it does not affect the behavior.

This topic does not answer the question and is five years old.

Thanks for your time!

EDIT: CTRL-E and CTRL-Y are behaving the same (scrolling by logical line, I guess for the same reason), display=lastline does not affect the behavior, neither does scrolloff.

Here's my vimrc, just in case.

  • it is not possible to scroll per visual screen line. Have you tried using CTRL-E/ CTRL-Y? This at least does not change the cursor position, but moves the view in the window. – Christian Brabandt Apr 21 at 13:21
  • CTRL-E / CTRL-Y also move one logical line down, I guess it's the same problem – Biggybi Apr 21 at 18:58
  • Scrolling by visual screen lines is indeed a feature I have long been wishing for, but so far nobody has implemented that feature (and it is not that easy). So no, it is currently not possible. – Christian Brabandt Apr 22 at 6:18

Browse other questions tagged or ask your own question.