Barbarian Meets Codingbarbarianmeetscoding

WebDev, UX & a Pinch of Fantasy

1 minute readfive-minutes-vim

5 Minutes Vim: Enabling Vim in Zsh

5 minutes vim. Learn cool stuff about vim in under 5 minutes

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!

Vim all the things! meme

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
)

Jaime González García

Written by Jaime González García , Dad, Husband, Front-end software engineer, UX designer, amateur pixel artist, tinkerer and master of the arcane arts. You should follow him on Twitter where he shares useful stuff! (and is funny too).Jaime González García