update keymap.md

pull/1039/head
Bob Qi 3 years ago
parent 0d1dd4603e
commit 9e458272b1

@ -234,24 +234,25 @@ Mappings in the style of [vim-unimpaired](https://github.com/tpope/vim-unimpaire
## Insert Mode ## Insert Mode
| Key | Description | Command | | Key | Description | Command |
| ----- | ----------- | ------- | | ----- | ----------- | ------- |
| `Escape` | Switch to normal mode | `normal_mode` | | `Escape` | Switch to normal mode | `normal_mode` |
| `Ctrl-x` | Autocomplete | `completion` | | `Ctrl-x` | Autocomplete | `completion` |
| `Ctrl-w` | Delete previous word | `delete_word_backward` | | `Ctrl-w` | Delete previous word | `delete_word_backward` |
| `Alt-b`, `Alt-Left` | Backward a word | | `Alt-d` | Delete next word | `delete_word_forward` |
| `Ctrl-b`, `Left` | Backward a char | | `Alt-b`, `Alt-Left` | Backward a word | `move_prev_word_end` |
| `Alt-f`, `Alt-Right` | Forward a word | | `Ctrl-b`, `Left` | Backward a char | `move_char_left` |
| `Ctrl-f`, `Right` | Forward a char | | `Alt-f`, `Alt-Right` | Forward a word | `move_next_word_start` |
| `Ctrl-e`, `End` | move to line end | | `Ctrl-f`, `Right` | Forward a char | `move_char_right` |
| `Ctrl-a`, `Home` | move to line start | | `Ctrl-e`, `End` | move to line end | `goto_line_end_newline` |
| `Ctrl-w` | delete previous word | | `Ctrl-a`, `Home` | move to line start | `goto_line_start` |
| `Ctrl-u` | delete to start of line | | `Ctrl-w` | delete previous word | `delete_word_backwar` |
| `Ctrl-k` | delete to end of line | | `Ctrl-u` | delete to start of line | `kill_to_line_start` |
| `backspace`, `Ctrl-h` | delete previous char | | `Ctrl-k` | delete to end of line | `kill_to_line_end` |
| `delete`, `Ctrl-d` | delete previous char | | `backspace`, `Ctrl-h` | delete previous char | `delete_char_backward` |
| `Ctrl-p`, `Up` | move to previous line | | `delete`, `Ctrl-d` | delete previous char | `delete_char_forward` |
| `Ctrl-n`, `Down` | move to next line | | `Ctrl-p`, `Up` | move to previous line | `move_line_up` |
| `Ctrl-n`, `Down` | move to next line | `move_line_down` |
## Select / extend mode ## Select / extend mode
@ -287,6 +288,7 @@ Keys to use within prompt, Remapping currently not supported.
| `Ctrl-e`, `End` | move prompt end | | `Ctrl-e`, `End` | move prompt end |
| `Ctrl-a`, `Home` | move prompt start | | `Ctrl-a`, `Home` | move prompt start |
| `Ctrl-w` | delete previous word | | `Ctrl-w` | delete previous word |
| `Alt-d` | delete next word |
| `Ctrl-u` | delete to start of line | | `Ctrl-u` | delete to start of line |
| `Ctrl-k` | delete to end of line | | `Ctrl-k` | delete to end of line |
| `backspace`, `Ctrl-h` | delete previous char | | `backspace`, `Ctrl-h` | delete previous char |

@ -229,6 +229,14 @@ impl Prompt {
self.completion = (self.completion_fn)(&self.line); self.completion = (self.completion_fn)(&self.line);
} }
pub fn delete_word_forwards(&mut self) {
let pos = self.eval_movement(Movement::ForwardWord(1));
self.line.replace_range(self.cursor..pos, "");
self.exit_selection();
self.completion = (self.completion_fn)(&self.line);
}
pub fn kill_to_start_of_line(&mut self) { pub fn kill_to_start_of_line(&mut self) {
let pos = self.eval_movement(Movement::StartOfLine); let pos = self.eval_movement(Movement::StartOfLine);
self.line.replace_range(pos..self.cursor, ""); self.line.replace_range(pos..self.cursor, "");
@ -484,6 +492,10 @@ impl Component for Prompt {
code: KeyCode::Char('w'), code: KeyCode::Char('w'),
modifiers: KeyModifiers::CONTROL, modifiers: KeyModifiers::CONTROL,
} => self.delete_word_backwards(), } => self.delete_word_backwards(),
KeyEvent {
code: KeyCode::Char('d'),
modifiers: KeyModifiers::ALT,
} => self.delete_word_forwards(),
KeyEvent { KeyEvent {
code: KeyCode::Char('k'), code: KeyCode::Char('k'),
modifiers: KeyModifiers::CONTROL, modifiers: KeyModifiers::CONTROL,

Loading…
Cancel
Save