Bind a delete key in vi mode
I am using vi-mode oh-my-zsh plugin. In mine .zshrc
I have
bindkey '^[[3~' delete-char
where ^[[3~
is the exit code of my delete key. However, this only works in insert mode, not in command mode. When i type
$ abcd
move the cursor to the beginning of the line and press del
in command mode, I get
$ abcd
therefore, obviously, the character sequence of the delete key is interpreted literally. How can I make the delete key actually delete the character in command mode?
source to share
bindkey -a '^[[3~' delete-char
Zsh has many different keyboard layouts, and by default bindkey will bind keys on a regular keyboard in insert mode. The command mode keyboard is selected with -M vicmd
. -a
is a shortcut for that. You can list keyboard layouts with bindkey -l
. You will see that there is also viopp
one that is used for movements after a type c or d key. Also visually for the visual selection mode.
source to share