I am using the vi-mode plugin of oh-my-zsh. In my .zshrc
, I have
bindkey '^[[3~' delete-char
where ^[[3~
is the escape code of my delete key. However, this only works in insert mode, but not in command mode. When I type
$ abcd
move the cursor to the beginning of the line and hit del
in command mode, I get
$ ABCd
so apparently the character sequence of the delete key is interpreted literally. How can I make the delete key actually delete a character in command mode?
Once in insert mode, you can type in your text. Press ENTER at the end of each line. Use Backspace to delete to the left of the cursor. If you need to move the cursor to another line, or make a change, or pretty much anything else, you need to press ESC to get back to Command mode first.
Fix Not Working Backspace in Vi/Vim To fix “not working” backspace key in the insert mode permanently, add set backspace=indent,eol,start command to vi / vim configuration file in your $HOME directory.
Use Ctrl + O in Insert mode to run one Normal mode command, so you can delete the current line without leaving Insert mode, with Ctrl + O d d .
bindkey -a '^[[3~' delete-char
Zsh has a variety of different keymaps and by default, bindkey will bind keys in the normal insert mode keymap. The command mode keymap is selected with -M vicmd
. -a
is a shortcut for that. You can list the keymaps with bindkey -l
. You'll see that there is also viopp
which is used for movements after a key like c or d. There's also visual for visual selection mode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With