df80a2da5475fc3c068bc5f700fa176a47f7adbe

Author
bretello <bretello@users.noreply.github.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(vi-mode): copy to clipboard when using `vi-change*` and `vi-yank*` widgets (#11861)

Diff

 1diff --git a/plugins/vi-mode/README.md b/plugins/vi-mode/README.md
 2index 0cb516751fe4c621aeca650d0a9342375509d869..821c12adbc5b63191db421526ed3b8e130a8ab88 100644
 3--- a/plugins/vi-mode/README.md
 4+++ b/plugins/vi-mode/README.md
 5@@ -144,11 +144,17 @@ NOTE: this used to be bound to `v`. That is now the default (`visual-mode`).
 6 - `c{motion}`   : Delete {motion} text and start insert
 7 - `cc`          : Delete line and start insert
 8 - `C`           : Delete to the end of the line and start insert
 9+- `P`           : Insert the contents of the clipboard before the cursor
10+- `p`           : Insert the contents of the clipboard after the cursor
11 - `r{char}`     : Replace the character under the cursor with {char}
12 - `R`           : Enter replace mode: Each character replaces existing one
13 - `x`           : Delete `count` characters under and after the cursor
14 - `X`           : Delete `count` characters before the cursor
15 
16+NOTE: delete/kill commands (`dd`, `D`, `c{motion}`, `C`, `x`,`X`) and yank commands
17+(`y`, `Y`) will copy to the clipboard. Contents can then be put back using paste commands
18+(`P`, `p`).
19+
20 ## Known issues
21 
22 ### Low `$KEYTIMEOUT`
23diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh
24index cc9817a7455cec6d6dfe7281f67731fe5df4557a..d1493e02f984bdd780b52a342b22d5a5b661c986 100644
25--- a/plugins/vi-mode/vi-mode.plugin.zsh
26+++ b/plugins/vi-mode/vi-mode.plugin.zsh
27@@ -147,8 +147,15 @@ function wrap_clipboard_widgets() {
28   done
29 }
30 
31-wrap_clipboard_widgets copy vi-yank vi-yank-eol vi-backward-kill-word vi-change-whole-line vi-delete vi-delete-char
32-wrap_clipboard_widgets paste vi-put-{before,after}
33+wrap_clipboard_widgets copy \
34+    vi-yank vi-yank-eol vi-yank-whole-line \
35+    vi-change vi-change-eol vi-change-whole-line \
36+    vi-kill-line vi-kill-eol vi-backward-kill-word \
37+    vi-delete vi-delete-char vi-backward-delete-char
38+
39+wrap_clipboard_widgets paste \
40+    vi-put-{before,after}
41+
42 unfunction wrap_clipboard_widgets
43 
44 # if mode indicator wasn't setup by theme, define default, we'll leave INSERT_MODE_INDICATOR empty by default