on master help sign in
Add yank_to_clipboard commands, bind to `<space>y` by default
d4f9716Michael Davis
book/src/keymap.md+1−1
@@ -291,7 +291,7 @@ This layer is a kludge of mappings, mostly pickers.
291| `w` | Enter [window mode](#window-mode) | N/A |
291| `w` | Enter [window mode](#window-mode) | N/A |
292| `p` | Paste system clipboard after selections | `paste_clipboard_after` |
292| `p` | Paste system clipboard after selections | `paste_clipboard_after` |
293| `P` | Paste system clipboard before selections | `paste_clipboard_before` |
293| `P` | Paste system clipboard before selections | `paste_clipboard_before` |
294−| `y` | Join and yank selections to clipboard | `yank_joined_to_clipboard` |
294+| `y` | Yank selections to clipboard | `yank_to_clipboard` |
295| `Y` | Yank main selection to clipboard | `yank_main_selection_to_clipboard` |
295| `Y` | Yank main selection to clipboard | `yank_main_selection_to_clipboard` |
296| `R` | Replace selections by clipboard contents | `replace_selections_with_clipboard` |
296| `R` | Replace selections by clipboard contents | `replace_selections_with_clipboard` |
297| `/` | Global search in workspace folder | `global_search` |
297| `/` | Global search in workspace folder | `global_search` |
helix-term/src/commands.rs+12
@@ -375,6 +375,8 @@ impl MappableCommand {
375 later, "Move forward in history",
375 later, "Move forward in history",
376 commit_undo_checkpoint, "Commit changes to new checkpoint",
376 commit_undo_checkpoint, "Commit changes to new checkpoint",
377 yank, "Yank selection",
377 yank, "Yank selection",
378+ yank_to_clipboard, "Yank selections to clipboard",
379+ yank_to_primary_clipboard, "Yank selections to primary clipboard",
378 yank_joined, "Join and yank selections",
380 yank_joined, "Join and yank selections",
379 yank_joined_to_clipboard, "Join and yank selections to clipboard",
381 yank_joined_to_clipboard, "Join and yank selections to clipboard",
380 yank_main_selection_to_clipboard, "Yank main selection to clipboard",
382 yank_main_selection_to_clipboard, "Yank main selection to clipboard",
@@ -3762,6 +3764,16 @@ fn yank(cx: &mut Context) {
3762 exit_select_mode(cx);
3764 exit_select_mode(cx);
3763}
3765}
3764
3766
3767+fn yank_to_clipboard(cx: &mut Context) {
3768+ yank_impl(cx.editor, '*');
3769+ exit_select_mode(cx);
3770+}
3771+
3772+fn yank_to_primary_clipboard(cx: &mut Context) {
3773+ yank_impl(cx.editor, '+');
3774+ exit_select_mode(cx);
3775+}
3776+
3765fn yank_impl(editor: &mut Editor, register: char) {
3777fn yank_impl(editor: &mut Editor, register: char) {
3766 let (view, doc) = current!(editor);
3778 let (view, doc) = current!(editor);
3767 let text = doc.text().slice(..);
3779 let text = doc.text().slice(..);
helix-term/src/keymap/default.rs+1−1
@@ -265,7 +265,7 @@ pub fn default() -> HashMap<Mode, KeyTrie> {
265 "C-v" | "v" => vsplit_new,
265 "C-v" | "v" => vsplit_new,
266 },
266 },
267 },
267 },
268− "y" => yank_joined_to_clipboard,
268+ "y" => yank_to_clipboard,
269 "Y" => yank_main_selection_to_clipboard,
269 "Y" => yank_main_selection_to_clipboard,
270 "p" => paste_clipboard_after,
270 "p" => paste_clipboard_after,
271 "P" => paste_clipboard_before,
271 "P" => paste_clipboard_before,