vim mode: ctrl+u/ctrl+d should move the cursor when scrolling has reached the end
Check for existing issues
- [X] Completed
Describe the feature
To see what I mean, open vim/nvim and put the cursor into the middle of the screen with M, then press ctrl+u repeatedly. Once the editor cannot scroll up anymore, the cursor moves to the top of the file. This doesn't happen in zed – the cursor position always stays fixed when using ctrl+u/ctrl+d.
I admit it's not a very important feature, but I thought I'd report it anyway.
If applicable, add mockups / screenshots to help present your vision of the feature
No response
Potentially related #8993
Oh yes, that seems highly related.
Not sure whether I should close this issue as duplicate.
EDIT: ah, there's a potential solution in the other issue. I will try it out
I'm going to close this thread in issue of the other one to keep the convo in one place. Be sure to follow up in the other thread if the potential solution doesn't work for you 👌
Duplicate of:
- #8993
I tried out the solution in #8993 (sorry for the delay):
{
"context": "Editor",
"bindings": {
"ctrl-d": "editor::MovePageDown",
"ctrl-u": "editor::MovePageUp"
}
},
and this does move the cursor, but it moves by a whole "page" (i.e., a whole screen), like ctrl+f and ctrl+b do in vim. So, this isn't a full solution, because ctrl+u and ctrl+d are supposed to only move by half the screen height.
So, some kind of editor::MoveScrollDown and editor::MoveScrollUp is needed?
(I also tried "ctrl-d": ["editor::MoveUpByLines", 19], where 19 is lines is about half my screen, but that also doesn't move the cursor.)
EDIT: actually, "ctrl-d": ["editor::MoveDownByLines", { "lines": 19 }] works, but, it's tied to my screen size
i achieved the desired effect with the following in my keymap.json file:
[
{
"context": "Editor",
"bindings": {
"ctrl-u": ["workspace::SendKeystrokes", "1 5 k z z"],
"ctrl-d": ["workspace::SendKeystrokes", "1 5 j z z"]
}
}
]
essentially it's mapping ctrl-u with 15 up keys followed by z z keys to center the scrolled to line in the screen. obviously 15 lines works with my font settings, you should adjust accordingly.