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+Right
Prior Art
- Fish shell:
Alt+Right accepts next word
- zsh-autosuggestions:
Ctrl+Right for partial accept
- GitHub Copilot CLI: Word-by-word accept
Related
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:
gitPressing Tab/Right accepts entire suggestion →
git commit -m "fix bug"Desired Behavior
Example:
git| Suggestion:commit -m "fix bug"git commit| Suggestion:-m "fix bug"git commit -m| Suggestion:"fix bug"Implementation
Prior Art
Alt+Rightaccepts next wordCtrl+Rightfor partial acceptRelated