aboutsummaryrefslogtreecommitdiff
path: root/98-bindkeys.zsh
diff options
context:
space:
mode:
Diffstat (limited to '98-bindkeys.zsh')
-rw-r--r--98-bindkeys.zsh14
1 files changed, 14 insertions, 0 deletions
diff --git a/98-bindkeys.zsh b/98-bindkeys.zsh
index 1c20068..f3bb40f 100644
--- a/98-bindkeys.zsh
+++ b/98-bindkeys.zsh
@@ -1,5 +1,16 @@
bindkey -v
+insert-last-word() {
+ # Trim trailing whitespace from LBUFFER
+ local trimmed="${LBUFFER%"${LBUFFER##*[![:space:]]}"}"
+
+ # Extract the last space-separated word
+ local last_word="${trimmed##* }"
+ LBUFFER+="$last_word"
+}
+
+zle -N insert-last-word
+
bindkey -M menuselect 'h' vi-backward-char
bindkey -M menuselect 'k' vi-up-line-or-history
bindkey -M menuselect 'l' vi-forward-char
@@ -16,6 +27,8 @@ autoload edit-command-line
zle -N edit-command-line
bindkey '' edit-command-line
+bindkey '' insert-last-word
+
# This allows a ctrl-w motion with neovim, so one does not have do a terminal
# escape to switch panes.
nvim-move-pane() {
@@ -130,4 +143,5 @@ bindkey -M vicmd '@' select-nvim-reg
bindkey -M vicmd 'p' put-after-reg-override
bindkey -M viins '' nvim-complete
+bindkey -M viins ' ' vi-forward-char