When navigating the jumplist, it is not obvious when the cursor will be centered in the view and when not. (With "view" I mean what is displayed on the screen.)
Exact steps to reproduce:
vim --clean +'set nu'
59o<ESC>
(now the buffer contains 60 empty lines):30
(go to line 30)gg<C-o>
will position the cursor at the bottom of the view (respecting scrolloff
which is set to 5
by default), and similarly G<C-o>
will position the cursor at the top of the view (again respecting scrolloff
).gg<C-o>
and G<C-o>
will position the cursor in the middle of the view.Since in all cases we jump to a location that is not in the current view, the different behavior seems odd to me.
I would expect a more intuitive behavior, i.e. a behavior that is deterministic, obvious and useful. Right now, the behavior is not obvious and not always useful, IMO. Ideas:
scrolloff
is not 0
, this might cause a bit of scrolling without centering the cursor.scrolloff
is not 0
, and might be even more ergonomic or "easier for the eye" in this case, since when the view scrolls, one immediately knows that the cursor will be centered in the screen, thus one does not have to search for the cursor. It might sound a bit nitpicky since it takes only a fraction of a second to locate the new cursor position, but it might lower the cognitive load and may add up if done hundreds of times a day.Ideally, the behavior could be configured using e.g. jumpoptions
.
9.1 Included patches: 1-80
OS: Archlinux
Terminal: foot 1.16.2
$TERM: foot-extra
Shell: bash 5.2.26
No response
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
Hm, thanks for your suggestion. I have mad a very quick patch here: chrisbra@fe4a04a
This misses test so is not yet ready to be included, but you may want to try it out.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.
@camoz @chrisbra My personal ideal behavior is to always center after jumping, unless bringing the destination line into view can be done while keeping some of the original view visible, in which case, scroll only as far as needed to bring the destination into view, i.e., the destination will be the bottom or top line of the window.
Example (assume scrolloff is 0 and wrap is off for simplicity):
The current view shows lines 21 through 30 (total 10 lines)
In general, jumping to any line between 12 through 39 would not cause centering, whereas jumping to lines below 12 or above 39 would cause centering.
I realize that wrapped lines would make calculating this less straightforward since a line could take up a variable amount of window/screen lines.
I think vim is currently intending to do some semblance of this. It seems like it is trying do something like "center if showing the destination line would require more than about half a window height lines of scrolling" but it doesn't appear to be exact, and perhaps there are weird edge cases and bugs that have built up over time, perhaps partly due to oversight when adding options like wrap, scrolloff, etc.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.