-
Notifications
You must be signed in to change notification settings - Fork 12
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Feature Request
Add ability to accept just the next word of a suggestion, not the entire thing.
Current Behavior
Suggestion: git commit -m "fix bug"
Buffer: git
Pressing Tab/Right accepts entire suggestion → git commit -m "fix bug"
Desired Behavior
- Tab / Right arrow: Accept full suggestion (current)
- Ctrl+Right: Accept next word only
Example:
- Buffer:
git| Suggestion:commit -m "fix bug" - Press Ctrl+Right → Buffer:
git commit| Suggestion:-m "fix bug" - Press Ctrl+Right → Buffer:
git commit -m| Suggestion:"fix bug"
Implementation
_aprender_accept_word() {
if [[ -n "$POSTDISPLAY" ]]; then
local suggestion="${POSTDISPLAY# }"
local next_word="${suggestion%% *}"
BUFFER="${BUFFER}${next_word} "
CURSOR=${#BUFFER}
# Update POSTDISPLAY with remainder
local remainder="${suggestion#$next_word}"
remainder="${remainder# }"
if [[ -n "$remainder" ]]; then
POSTDISPLAY=" $remainder"
region_highlight=("${#BUFFER} $((${#BUFFER} + ${#POSTDISPLAY})) fg=8")
else
POSTDISPLAY=""
region_highlight=()
fi
zle redisplay
else
zle forward-word
fi
}
zle -N _aprender_accept_word
bindkey '^[[1;5C' _aprender_accept_word # Ctrl+RightPrior Art
- Fish shell:
Alt+Rightaccepts next word - zsh-autosuggestions:
Ctrl+Rightfor partial accept - GitHub Copilot CLI: Word-by-word accept
Related
- Part of ZSH widget improvements (ZSH widget: Add toggle, fix keybindings, add timeout for robustness #83)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request