vi-mode
vi-mode copied to clipboard
Oh-my-zsh plugin for vim emulation, but actually usable
trafficstars
vi-mode
This plugin increase vi-like zsh functionality.
- Line cursor in insert mode
- Block cursor in normal and visual mode
- Mode indicator
Use ESC or CTRL-[ to enter Normal mode.
History
ctrl-p: Previous command in historyctrl-n: Next command in history
Mode indicators
Mode are indicated by the right prompt when not defined by theme. You can override the default by changing the corresponding variables:
$INSERT_MODE_INDICATOR
$NORMAL_MODE_INDICATOR
$VISUAL_MODE_INDICATOR
Example:
NORMAL_MODE_INDICATOR="%{$FX[italic]$FG[201]%}NORMAL%{$FX[reset]%}"Will display NORMAL in italic purple when in vicmd (normal) mode
Vim edition
ctrl-v: Edit current command line in Vimv: Visual mode (works better with zsh-vimode-visual)
Movement
$: To the end of the line^: To the first non-blank character of the line0: To the first character of the linew: [count] words forwardW: [count] WORDS forwarde: Forward to the end of word [count] inclusiveE: Forward to the end of WORD [count] inclusiveb: [count] words backwardB: [count] WORDS backwardt{char}: Till before [count]'th occurrence of {char} to the rightT{char}: Till before [count]'th occurrence of {char} to the leftf{char}: To [count]'th occurrence of {char} to the rightF{char}: To [count]'th occurrence of {char} to the left;: Repeat latest f, t, F or T [count] times,: Repeat latest f, t, F or T in opposite direction
Insertion
i: Insert text before the cursorI: Insert text before the first character in the linea: Append text after the cursorA: Append text at the end of the lineo: Insert new command line below the current oneO: Insert new command line above the current one
Delete and Insert
ctrl-h: While in Insert mode: delete character before the cursorctrl-w: While in Insert mode: delete word before the cursord{motion}: Delete text that {motion} moves overdd: Delete lineD: Delete characters under the cursor until the end of the linec{motion}: Delete {motion} text and start insertcc: Delete line and start insertC: Delete to the end of the line and start insertr{char}: Replace the character under the cursor with {char}R: Enter replace mode: Each character replaces existing onex: Delete [count] characters under and after the cursorX: Delete [count] characters before the cursor
Installation
Zplug
- Add this to your zplug section
zplug "nyquase/vi-mode"
zplug "b4b4r07/zsh-vimode-visual", defer:3
My recommended zplug plugins
zplug "nyquase/vi-mode"
zplug "zsh-users/zsh-autosuggestions"
zplug "zsh-users/zsh-completions"
zplug "zdharma/fast-syntax-highlighting", defer:2
zplug "b4b4r07/zsh-vimode-visual", defer:3
Manual (Git Clone)
- Clone this repository somewhere on your machine.
git clone https://github.com/nyquase/vi-mode ~/.zsh/vi-mode
- Add the following to your
.zshrc:
source ~/.zsh/vi-mode/vi-mode.zsh
- Start a new terminal session.
Oh My Zsh
- Clone this repository into
ZSH_CUSTOM/plugins(by default~/.oh-my-zsh/custom/plugins)
# If you want better visual mode
git clone https://github.com/b4b4r07/zsh-vimode-visual ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-vimode-visual
git clone https://github.com/nyquase/vi-mode ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/vi-mode
- Add the plugin to the list of plugins for Oh My Zsh to load (inside
.zshrc):
plugins=(vi-mode zsh-vimode-visual)
This will override the default Oh My Zsh vi-mode if you were using it
- Start a new terminal session.