Zsh’s vi Mode

Alex R. Young
usevim
Published in
1 min readNov 9, 2013

If you find Zsh’s shortcuts awkward, then you might be pleased to know it can be switched into vi mode. It supports vi line editing mode which can be enabled with bindkey -v.

Shells that use Readline can be set to use vi mode by setting the following in ~/.inputrc:

set editing-mode vi
set blink-matching-paren on

Zsh doesn’t use Readline, however, so it will check if you want to use vi or Emacs shortcuts based on the $EDITOR variable. You can override the setting with bindkey -v for vi or bindkey -e for Emacs.

It’s worth trying out vi mode just to see how it works — pressing <Esc> allows you to edit and navigate lines just like vi.

While researching this article I found Adding Vi To Your Zsh by Doug Black, which has a lot of background on vi mode and a script for displaying the current mode.

--

--