Add Vim buffer jump motions (#40958)

## What changed

- Add `gg` and `G` motions to jump to the first and last buffer lines.
- Support the motions with delete, change, and yank operators, including dot-repeat for edits.
- Expose normal-mode and operator-motion bindings in the configurable keymap while preserving conflicting user bindings.

## Testing

- Cover buffer jumps, operator combinations, repeat behavior, chord routing, and custom remapping.

GitOrigin-RevId: 24a9178cf7964053aaf9a8cd268c5434dda0778e
This commit is contained in:
Benjamin Carlsson authored and copyberry committed 2026-08-26 19:31:52 +00:00
1 parent 6ac012a0d4
commit d47e5cc0e2
17 files changed
+433 -13

No files matched your search

+8
View File
@@ -140,6 +140,8 @@ pub(super) const KEYMAP_ACTIONS: &[KeymapActionDescriptor] = &[
action("vim_normal", "Vim normal", "find_backward", "Find the previous character on the current line."),
action("vim_normal", "Vim normal", "till_forward", "Stop before the next character on the current line."),
action("vim_normal", "Vim normal", "till_backward", "Stop after the previous character on the current line."),
action("vim_normal", "Vim normal", "jump_top", "Jump to the first buffer line."),
action("vim_normal", "Vim normal", "jump_bottom", "Jump to the last buffer line."),
action("vim_normal", "Vim normal", "delete_char", "Delete the character under the cursor."),
action("vim_normal", "Vim normal", "replace_char", "Replace the character under the cursor."),
action("vim_normal", "Vim normal", "repeat_last_change", "Repeat the last complete edit."),
@@ -167,6 +169,8 @@ pub(super) const KEYMAP_ACTIONS: &[KeymapActionDescriptor] = &[
action("vim_operator", "Vim operator", "motion_find_backward", "Operator motion to the previous character on the current line."),
action("vim_operator", "Vim operator", "motion_till_forward", "Stop before the next character on the current line."),
action("vim_operator", "Vim operator", "motion_till_backward", "Stop after the previous character on the current line."),
action("vim_operator", "Vim operator", "motion_jump_top", "Operator motion to the first buffer line."),
action("vim_operator", "Vim operator", "motion_jump_bottom", "Operator motion to the last buffer line."),
action("vim_operator", "Vim operator", "select_inner_text_object", "Select an inner text object."),
action("vim_operator", "Vim operator", "select_around_text_object", "Select an around text object."),
action("vim_operator", "Vim operator", "cancel", "Cancel the pending operator."),
@@ -302,6 +306,8 @@ pub(super) fn binding_slot<'a>(
("vim_normal", "find_backward") => Some(&mut keymap.vim_normal.find_backward),
("vim_normal", "till_forward") => Some(&mut keymap.vim_normal.till_forward),
("vim_normal", "till_backward") => Some(&mut keymap.vim_normal.till_backward),
("vim_normal", "jump_top") => Some(&mut keymap.vim_normal.jump_top),
("vim_normal", "jump_bottom") => Some(&mut keymap.vim_normal.jump_bottom),
("vim_normal", "delete_char") => Some(&mut keymap.vim_normal.delete_char),
("vim_normal", "replace_char") => Some(&mut keymap.vim_normal.replace_char),
("vim_normal", "repeat_last_change") => Some(&mut keymap.vim_normal.repeat_last_change),
@@ -329,6 +335,8 @@ pub(super) fn binding_slot<'a>(
("vim_operator", "motion_find_backward") => Some(&mut keymap.vim_operator.motion_find_backward),
("vim_operator", "motion_till_forward") => Some(&mut keymap.vim_operator.motion_till_forward),
("vim_operator", "motion_till_backward") => Some(&mut keymap.vim_operator.motion_till_backward),
("vim_operator", "motion_jump_top") => Some(&mut keymap.vim_operator.motion_jump_top),
("vim_operator", "motion_jump_bottom") => Some(&mut keymap.vim_operator.motion_jump_bottom),
("vim_operator", "select_inner_text_object") => Some(&mut keymap.vim_operator.select_inner_text_object),
("vim_operator", "select_around_text_object") => Some(&mut keymap.vim_operator.select_around_text_object),
("vim_operator", "cancel") => Some(&mut keymap.vim_operator.cancel),