From a89b147d81821a884fb6f19f56d68be5f079dc6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20CORTIER?= Date: Wed, 18 May 2022 15:32:51 -0400 Subject: [PATCH] feat(term): add Ctrl+{Left/Right} for word-wise movement Ctrl-Left and Ctrl-Right are common shortcuts in numerous applications. This change is just adding a new key binding for the existing word-wise movement: - Ctrl-Left is equivalent to Alt-b and Alt-Left, and - Ctrl-Right is equivalent to Alt-f and Alt-Right. --- book/src/keymap.md | 42 +++++++++++++++++------------------ helix-term/src/application.rs | 2 +- helix-term/src/ui/prompt.rs | 4 ++-- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/book/src/keymap.md b/book/src/keymap.md index 9d5d084177898..c8c45eb16b4ba 100644 --- a/book/src/keymap.md +++ b/book/src/keymap.md @@ -349,25 +349,25 @@ Keys to use within picker. Remapping currently not supported. Keys to use within prompt, Remapping currently not supported. -| Key | Description | -| ----- | ------------- | -| `Escape`, `Ctrl-c` | Close prompt | -| `Alt-b`, `Alt-Left` | Backward a word | -| `Ctrl-b`, `Left` | Backward a char | -| `Alt-f`, `Alt-Right` | Forward a word | -| `Ctrl-f`, `Right` | Forward a char | -| `Ctrl-e`, `End` | Move prompt end | -| `Ctrl-a`, `Home` | Move prompt start | -| `Ctrl-w` | Delete previous word | -| `Alt-d` | Delete next word | -| `Ctrl-u` | Delete to start of line | -| `Ctrl-k` | Delete to end of line | -| `backspace`, `Ctrl-h` | Delete previous char | -| `delete`, `Ctrl-d` | Delete next char | -| `Ctrl-s` | Insert a word under doc cursor, may be changed to Ctrl-r Ctrl-w later | -| `Ctrl-p`, `Up` | Select previous history | -| `Ctrl-n`, `Down` | Select next history | -| `Tab` | Select next completion item | -| `BackTab` | Select previous completion item | -| `Enter` | Open selected | +| Key | Description | +| ----- | ------------- | +| `Escape`, `Ctrl-c` | Close prompt | +| `Alt-b`, `Alt-Left`, `Ctrl-Left` | Backward a word | +| `Ctrl-b`, `Left` | Backward a char | +| `Alt-f`, `Alt-Right`, `Ctrl-Right` | Forward a word | +| `Ctrl-f`, `Right` | Forward a char | +| `Ctrl-e`, `End` | Move prompt end | +| `Ctrl-a`, `Home` | Move prompt start | +| `Ctrl-w` | Delete previous word | +| `Alt-d` | Delete next word | +| `Ctrl-u` | Delete to start of line | +| `Ctrl-k` | Delete to end of line | +| `backspace`, `Ctrl-h` | Delete previous char | +| `delete`, `Ctrl-d` | Delete next char | +| `Ctrl-s` | Insert a word under doc cursor, may be changed to Ctrl-r Ctrl-w later | +| `Ctrl-p`, `Up` | Select previous history | +| `Ctrl-n`, `Down` | Select next history | +| `Tab` | Select next completion item | +| `BackTab` | Select previous completion item | +| `Enter` | Open selected | diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index 2dfccf0435ecd..547fdd9f9b596 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -290,7 +290,7 @@ impl Application { } fn refresh_config(&mut self) { - let config = Config::load(helix_loader::config_file()).unwrap_or_else(|err| { + let config = Config::load_default().unwrap_or_else(|err| { self.editor.set_error(err.to_string()); Config::default() }); diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index ef08edf2d836f..88dea06162c4b 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -459,8 +459,8 @@ impl Component for Prompt { (self.callback_fn)(cx, &self.line, PromptEvent::Abort); return close_fn; } - alt!('b') | alt!(Left) => self.move_cursor(Movement::BackwardWord(1)), - alt!('f') | alt!(Right) => self.move_cursor(Movement::ForwardWord(1)), + alt!('b') | alt!(Left) | ctrl!(Left) => self.move_cursor(Movement::BackwardWord(1)), + alt!('f') | alt!(Right) | ctrl!(Right) => self.move_cursor(Movement::ForwardWord(1)), ctrl!('b') | key!(Left) => self.move_cursor(Movement::BackwardChar(1)), ctrl!('f') | key!(Right) => self.move_cursor(Movement::ForwardChar(1)), ctrl!('e') | key!(End) => self.move_end(),