Can I use both Emacs and Vim keybindings in zsh?

Yes, you can. It is even part of the default bindings.

To get emacs-like bindings for "insert-mode", you simply set emacs as default keymap. This is already the case, unless either of the VISUAL or EDITOR environment variables contain the string vi and unless you set it to viins explicitly with bindkey -v. You can also set it explicitly with bindkey -e.

From emacs mode you can then switch to vicmd mode ("normal-mode") with the key sequence ^X^V, that is Ctrl+x followed by Ctrl+v. To get back to emacs mode just type any key sequence that would normally get you to viins mode ("insert-mode") with vi-like bindings, e.g. i or a.

Tags:

Zsh