zsh-users / zsh-autosuggestions

Fish-like autosuggestions for zsh
MIT License
30.81k stars 1.85k forks source link

i cant find a way to unmap the right arrow key #618

Closed alexzanderr closed 2 years ago

alexzanderr commented 3 years ago

by default the right arrow key triggers autosuggestion completion. okey.

i want to disable it, because when i paste commands and i navigate with arrows to edit the auto suggestion messes up my command and i have to start over.

hoping for help. thanks

ericfreese commented 3 years ago

Type into zsh: bindkey ' and then press ctrl + V and the right arrow key then add the closing ' and press enter.

When I do this I get the following:

% bindkey '^[[C'        
"^[[C" vi-forward-char

That means that my right arrow key is bound to the vi-forward-char widget. Yours may be bound to plain forward-char or something else.

You need to remove whatever widget your right arrow key is bound to from the ZSH_AUTOSUGGEST_ACCEPT_WIDGETS array. In my case, to remove vi-forward-char, I would add this to my ~/.zshrc file:

# Based on this stack overflow answer of how to remove an element from an array
# https://stackoverflow.com/a/25172688/154703
ZSH_AUTOSUGGEST_ACCEPT_WIDGETS[$ZSH_AUTOSUGGEST_ACCEPT_WIDGETS[(i)vi-forward-char]]=()
alexzanderr commented 2 years ago

having this in .zshrc:

ZSH_AUTOSUGGEST_ACCEPT_WIDGETS[$ZSH_AUTOSUGGEST_ACCEPT_WIDGETS[(i)forward-char]]=()

disables the auto suggestion complete. thanks.

but how do i remap to tab or something else ?

alexzanderr commented 2 years ago

i want to remap to this key '^[c' (alt+c).

how do i achieve that?

ericfreese commented 2 years ago

Try bindkey '^[c' autosuggest-accept

alexzanderr commented 2 years ago

works like a charm. thanks.