summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbretello <bretello@users.noreply.github.com>2023-10-02 20:41:01 +0200
committerGitHub <noreply@github.com>2023-10-02 20:41:01 +0200
commitdf80a2da5475fc3c068bc5f700fa176a47f7adbe (patch)
treef44ee89187416252b2de5f6b70ce08bc378c7aea
parentfea4584cebf98fc58334b7cca841ab1ef224a35e (diff)
downloadzsh-df80a2da5475fc3c068bc5f700fa176a47f7adbe.tar.gz
zsh-df80a2da5475fc3c068bc5f700fa176a47f7adbe.tar.bz2
zsh-df80a2da5475fc3c068bc5f700fa176a47f7adbe.zip
feat(vi-mode): copy to clipboard when using `vi-change*` and `vi-yank*` widgets (#11861)
-rw-r--r--plugins/vi-mode/README.md6
-rw-r--r--plugins/vi-mode/vi-mode.plugin.zsh11
2 files changed, 15 insertions, 2 deletions
diff --git a/plugins/vi-mode/README.md b/plugins/vi-mode/README.md
index 0cb516751..821c12adb 100644
--- a/plugins/vi-mode/README.md
+++ b/plugins/vi-mode/README.md
@@ -144,11 +144,17 @@ NOTE: this used to be bound to `v`. That is now the default (`visual-mode`).
- `c{motion}` : Delete {motion} text and start insert
- `cc` : Delete line and start insert
- `C` : Delete to the end of the line and start insert
+- `P` : Insert the contents of the clipboard before the cursor
+- `p` : Insert the contents of the clipboard after the cursor
- `r{char}` : Replace the character under the cursor with {char}
- `R` : Enter replace mode: Each character replaces existing one
- `x` : Delete `count` characters under and after the cursor
- `X` : Delete `count` characters before the cursor
+NOTE: delete/kill commands (`dd`, `D`, `c{motion}`, `C`, `x`,`X`) and yank commands
+(`y`, `Y`) will copy to the clipboard. Contents can then be put back using paste commands
+(`P`, `p`).
+
## Known issues
### Low `$KEYTIMEOUT`
diff --git a/plugins/vi-mode/vi-mode.plugin.zsh b/plugins/vi-mode/vi-mode.plugin.zsh
index cc9817a74..d1493e02f 100644
--- a/plugins/vi-mode/vi-mode.plugin.zsh
+++ b/plugins/vi-mode/vi-mode.plugin.zsh
@@ -147,8 +147,15 @@ function wrap_clipboard_widgets() {
done
}
-wrap_clipboard_widgets copy vi-yank vi-yank-eol vi-backward-kill-word vi-change-whole-line vi-delete vi-delete-char
-wrap_clipboard_widgets paste vi-put-{before,after}
+wrap_clipboard_widgets copy \
+ vi-yank vi-yank-eol vi-yank-whole-line \
+ vi-change vi-change-eol vi-change-whole-line \
+ vi-kill-line vi-kill-eol vi-backward-kill-word \
+ vi-delete vi-delete-char vi-backward-delete-char
+
+wrap_clipboard_widgets paste \
+ vi-put-{before,after}
+
unfunction wrap_clipboard_widgets
# if mode indicator wasn't setup by theme, define default, we'll leave INSERT_MODE_INDICATOR empty by default