Move cursor one word left/right

This commit is contained in:
Joscha 2022-08-07 00:25:53 +02:00
parent 51d03c6fe2
commit 9ebe2361a9
2 changed files with 48 additions and 0 deletions

View file

@ -54,6 +54,8 @@ pub fn list_editor_key_bindings(
// Cursor movement
bindings.binding("ctrl+b, ←", "move cursor left");
bindings.binding("ctrl+f, →", "move cursor right");
bindings.binding("alt+b, ctrl+←", "move cursor left a word");
bindings.binding("alt+f, ctrl+→", "move cursor right a word");
bindings.binding("ctrl+a, home", "move cursor to start of line");
bindings.binding("ctrl+e, end", "move cursor to end of line");
bindings.binding("↑/↓", "move cursor up/down");
@ -86,6 +88,8 @@ pub fn handle_editor_key_event(
// Cursor movement
key!(Ctrl + 'b') | key!(Left) => editor.move_cursor_left(terminal.frame()),
key!(Ctrl + 'f') | key!(Right) => editor.move_cursor_right(terminal.frame()),
key!(Alt + 'b') | key!(Ctrl + Left) => editor.move_cursor_left_a_word(terminal.frame()),
key!(Alt + 'f') | key!(Ctrl + Right) => editor.move_cursor_right_a_word(terminal.frame()),
key!(Ctrl + 'a') | key!(Home) => editor.move_cursor_to_start_of_line(terminal.frame()),
key!(Ctrl + 'e') | key!(End) => editor.move_cursor_to_end_of_line(terminal.frame()),
key!(Up) => editor.move_cursor_up(terminal.frame()),