Scrolling behavior when using gj and gk is jumpy

31 views
Skip to first unread message

Marc Adler

unread,
Oct 10, 2025, 5:38:04 PM (5 days ago) Oct 10
to vim_use

I use Vim to write text, ie prose with paragraphs.


Vim interprets a paragraph as a single line, but it's good at displaying line breaks anyway.


The problem is that it skips up and down by paragraph when you scroll up and down with gj and gk, making the text jerky and difficult to read.


Smoothscroll fixes this, but only when you're scrolling down.


Is there a way to make it work when scrolling up?


Here's an example of what I'm talking about. The first is Vim (Neovim) and the second is VSCode. The VSCode behavior is what you see in every other text editor. 


Vim:

https://imgur.com/a/u83V2TA


VSCode:

https://imgur.com/a/8dhcXo1


Is there a way to fix this? Like I said, this behavior is unique to Vim. 

Yee Cheng Chin

unread,
Oct 11, 2025, 5:25:03 AM (4 days ago) Oct 11
to vim...@googlegroups.com
I don't think the issue is asymmetric as you claimed? gj/gk exhibits
the same jumping behavior both up and down (which is also shown in
your video). When you go to a new line, Vim tries to fit the entire
wrapped line with the cursor in the whole screen which is why it feels
jumpy. I don't think there is a builtin way to fix this. You could
write a script to re-scroll the text using Ctrl-E/Ctrl-Y when you do
gj/gk to get around this issue though. You could of course file an
issue to Vim to see if there will be an appetite to add this as an
option.
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/vim_use/6ac646eb-a298-4540-be5f-5e5b884a1803n%40googlegroups.com.

Romain Lafourcade

unread,
Oct 12, 2025, 2:47:22 AM (3 days ago) Oct 12
to vim_use
The purpose of j, k, gj, and gk is to _position the cursor_ for the next editing command.

They might also move the buffer up or down relative to the viewport, but that is only a _side effect_ of having the cursor at the top or bottom of the window.

:help 'smoothscroll' works perfectly, but _for actual "scrolling" commands_, which j, k, gj, and gk are not. 

Use Ctrl-E, Ctrl-Y, etc. to _scroll_.

See :help scrolling.

Marc Adler

unread,
Oct 13, 2025, 9:23:24 AM (2 days ago) Oct 13
to vim_use
"You could of course file an issue to Vim to see if there will be an appetite to add this as an option."

I just found the vim dev group. I'll post there. It's a little weird that Vim is the only text editor that has this behavior.

Marc Adler

unread,
Oct 13, 2025, 9:23:32 AM (2 days ago) Oct 13
to vim_use
I understand that, but my main point is that positioning the cursor serves as a way to scroll in basically every other text editor on earth and it would be nice if it did here, too.

Plus, even if I scroll with ctl-e etc, the second I move my cursor into the "paragraph," it'll do that jerky jump. 

Romain Lafourcade

unread,
Oct 14, 2025, 1:44:08 AM (yesterday) Oct 14
to vim_use
> I understand that, but my main point is that positioning the cursor serves as a way to scroll in basically every other text editor on earth and it would be nice if it did here, too.

Moving the cursor and scrolling are two different things, with the former _sometimes_ causing the latter.
Doing the former in order to obtain the latter is, well… not a very efficient use of your tools.
Especially when a) there is a whole set of commands and widgets for doing the latter (<C-e>/<C-y>/etc., scrollbars, mousewheel, trackpad…) and b) it doesn't work particularly well to begin with.

It is the same side effect at play in every text editor and every multi-line text input widget on every platform, Vim included: you are moving the cursor to a line that is outside the viewport so the viewport is moved to include that line.
Where Vim's behavior might be different from other editors in that case is how it handles wrapped lines.
And how it does it makes perfect sense given the actual purpose of jkgjgk: the full _line_ is displayed so that you can _edit_ it comfortably.

> Plus, even if I scroll with ctl-e etc, the second I move my cursor into the "paragraph," it'll do that jerky jump. 

Not with :set smoothscroll.

If you want to _scroll_, use scrolling commands (in Vim and elsewhere).
They exist for that specific purpose and they will always be better than unrelated commands that may or may not cause scrolling.
If you want pixel-perfect scrolling, use a modern non-terminal based editor.

Reply all
Reply to author
Forward
0 new messages