Last Updated: February 25, 2016
·
1.427K
· copenhas

VI keymap for zsh

Although a bit confusing at first it's nice to be able to reuse many programmed in (mentally that is) keys. Lets get a run down:

Add to .zshrc:

bindkey -v

May the source be with you:

source ~/.zshrc

Now what does this mean? You'll basically start off in "insert" mode when the prompt comes up. Everything will work as normal, but you'll be able to Esc out to what is basically "normal" mode.

Basic "normal" mode:

h - move cursor back 1 character
l - move cursor forward 1 character

j - move back in history
k - move forward in history

/ - search backwards in history
? - search forward in history

Returning back to "insert" mode works:

i - at cursor
I - at beginning of line
a - after cursor
A - at end of line

Besides that everything is going to fall into place out of muscle memory. Most movements (^, $, w, e, b, %, others) seem to work great. So do yank and delete actions, but no "visual" mode for selection or any mode indication (possible doable through custom prompt?).

Enjoy.