Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup Vi Editing Mode for zsh

Tags:

vi

zsh

I want to set vi in editing mode in zsh (I am using oh-my-zsh) at start automatically when I open my shell, so at the beginning of my .zshrc I have tried the following code:

set -o vi

or

bindkey -v

but when pressing enter in the shell I cannot enter the vi mode.

If I tried one of the two commands in the shell, it works.

Basically I want zsh to start in vi edit mode.

Any ideas how to solve this problem?

like image 673
Radex Avatar asked Oct 01 '19 14:10

Radex


2 Answers

bindkey -v is enough to enable vi mode in ZSH. If you are worried the setting will be overwritten by another plugin, put the setting at the bottom of your ~/.zshrc.

After vi mode is enabled, you enter the "insert" mode by default. To enter "normal" mode, use Esc. And i or a to switch back to "insert" mode.

BTW, softmoth/zsh-vim-mode is the most powerful vim mode plugin I've ever used in ZSH.

like image 107
Simba Avatar answered Sep 21 '22 15:09

Simba


If you are using https://ohmyz.sh/ you can add vi-mode to the list of plugins in ~/.zshrc:

plugins=(git vi-mode) 
like image 37
olore Avatar answered Sep 18 '22 15:09

olore