From b66d3d3d9dccbb9c28d8611c4a0fc5d74ccb27d6 Mon Sep 17 00:00:00 2001 From: Omnikar Date: Thu, 9 Dec 2021 21:46:24 -0500 Subject: [PATCH] Add `save_selection` command (#1247) --- book/src/keymap.md | 1 + helix-term/src/commands.rs | 7 +++++++ helix-term/src/keymap.rs | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/book/src/keymap.md b/book/src/keymap.md index e1b1bad84..5a804c3c0 100644 --- a/book/src/keymap.md +++ b/book/src/keymap.md @@ -34,6 +34,7 @@ | `Ctrl-d` | Move half page down | `half_page_down` | | `Ctrl-i` | Jump forward on the jumplist | `jump_forward` | | `Ctrl-o` | Jump backward on the jumplist | `jump_backward` | +| `Ctrl-s` | Save the current selection to the jumplist | `save_selection` | | `v` | Enter [select (extend) mode](#select--extend-mode) | `select_mode` | | `g` | Enter [goto mode](#goto-mode) | N/A | | `m` | Enter [match mode](#match-mode) | N/A | diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 1f7a22755..87c5a63f6 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -362,6 +362,7 @@ impl MappableCommand { expand_selection, "Expand selection to parent syntax node", jump_forward, "Jump forward on jumplist", jump_backward, "Jump backward on jumplist", + save_selection, "Save the current selection to the jumplist", jump_view_right, "Jump to the split to the right", jump_view_left, "Jump to the split to the left", jump_view_up, "Jump to the split above", @@ -5285,6 +5286,12 @@ fn jump_backward(cx: &mut Context) { }; } +fn save_selection(cx: &mut Context) { + push_jump(cx.editor); + cx.editor + .set_status("Selection saved to jumplist".to_owned()); +} + fn rotate_view(cx: &mut Context) { cx.editor.focus_next() } diff --git a/helix-term/src/keymap.rs b/helix-term/src/keymap.rs index 9debbbacf..b1613252b 100644 --- a/helix-term/src/keymap.rs +++ b/helix-term/src/keymap.rs @@ -641,7 +641,7 @@ impl Default for Keymaps { "tab" => jump_forward, // tab == "C-o" => jump_backward, - // "C-s" => save_selection, + "C-s" => save_selection, "space" => { "Space" "f" => file_picker,