From 95380088436ba5a4ae9b4cf9a11070a96246bc0c Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Thu, 30 Jan 2025 22:02:28 +0000 Subject: Add more zsh bindings. --- 98-bindkeys.zsh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 -- cgit