5 Minutes Vim: Enabling Vim in Zsh
Once you start getting comfy using Vim you’ll inevitably arrive to that honeymoon phase where you yearn to have Vim available everywhere: all your editors, your browser, your email, your terminal, Vim everywhere! Vim all the things!
Ok… If your terminal of choice is zsh you’re in luck because it has built-in support for vi mode. Add this to your .zshrc
:
# Enable vi mode
bindkey -v
Restart zsh or refresh your configuration source ~/.zshrc
and you are good to go.
From now on whenever you open your zsh terminal you’ll be in Insert mode. Type ESC
to go into Normal mode and enjoy a trimmed down Vim experience and the most common Vim motions right within your terminal. When you’re done with your editing, type i
or a
to go back into Insert mode and have fun.
If you use oh-my-zsh, you can enhance your zsh Vim experience with the vi-mode plugin which sits on tops of the built-in vi mode and improves it with additional key bindings and an improved command prompt that tells you when you’re in Normal mode.
In order to activate this plugin, update the plugins
section of yhour .zshrc
file like so:
# Which plugins would you like to load? (plugins can be found in ~/.oh-my-zsh/plugins/*)
# Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
plugins=(
vi-mode
)
Written by Jaime González García , dad, husband, software engineer, ux designer, amateur pixel artist, tinkerer and master of the arcane arts. You can also find him on Twitter jabbering about random stuff.