All the vi mode keybindings work as expected. However, when I go into normal mode, my prompt stays in insert mode.
As you can see in the gif, I enter some words in insert mode. Then I hit esc to go into normal mode. I use b, e, dd, and p and the whole time the prompt says INSERT.

Operating system: Linux Zeus 4.11.6-3-ARCH #1 SMP PREEMPT Thu Jun 22 12:21:46 CEST 2017 x86_64 GNU/Linux
Terminal emulator: termite
ZSH version: zsh 5.3.1 (x86_64-unknown-linux-gnu)
.zshrcexport ZSH=/home/marcel/.oh-my-zsh
ZSH_THEME="spaceship"
SPACESHIP_DIR_TRUNC=0
SPACESHIP_VI_MODE_SHOW=true
SPACESHIP_VI_MODE_PREFIX=""
SPACESHIP_VI_MODE_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX"
SPACESHIP_VI_MODE_INSERT="[INSERT]"
SPACESHIP_VI_MODE_NORMAL="[NORMAL]"
SPACESHIP_VI_MODE_COLOR="white"
plugins=(git,vi-mode)
source "$ZSH/oh-my-zsh.sh"
for file in /home/marcel/.dotfiles/zsh/{exports,aliases,functions,secret}.sh; do
[ -r "$file" ] && [ -f "$file" ] && source "$file";
done;
(hash wal 2>/dev/null && wal -r -t &)
DEFAULT_USER="marcel"
eval $(thefuck --alias)
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
bindkey -v
Please, read Vi-mode section in README.md. It says:
Note: For oh-my-zsh users with vi-mode plugin enabled: Add
export RPS1="%{$reset_color%}"beforesource $ZSH/oh-my-zsh.shin.zshrcto disable default<<<NORMAL mode indicator in right prompt.
As I saw from your .zshrc, you didn't do this. Please let me know if it helps.
I feel stupid. Don't know how I missed that.
Never mind. I have added that and I still get the issue.
New .zshrc:
export ZSH=/home/marcel/.oh-my-zsh
export FPATH=/usr/share/zsh/site-functions:/usr/share/zsh/functions/Calendar:/usr/share/zsh/functions/Chpwd:/usr/share/zsh/functions/Completion:/usr/share/zsh/functions/Completion/Base:/usr/share/zsh/functions/Completion/Linux:/usr/share/zsh/functions/Completion/Unix:/usr/share/zsh/functions/Completion/X:/usr/share/zsh/functions/Completion/Zsh:/usr/share/zsh/functions/Exceptions:/usr/share/zsh/functions/Math:/usr/share/zsh/functions/MIME:/usr/share/zsh/functions/Misc:/usr/share/zsh/functions/Newuser:/usr/share/zsh/functions/Prompts:/usr/share/zsh/functions/TCP:/usr/share/zsh/functions/VCS_Info:/usr/share/zsh/functions/VCS_Info/Backends:/usr/share/zsh/functions/Zftp:/usr/share/zsh/functions/Zle
ZSH_THEME="spaceship"
SPACESHIP_DIR_TRUNC=0
SPACESHIP_EXEC_TIME_SHOW=false
export RPS1="%{$reset_color%}"
plugins=(git,vi-mode)
source "$ZSH/oh-my-zsh.sh"
for file in /home/marcel/.dotfiles/omzsh/{exports,aliases,functions,secret}.sh; do
[ -r "$file" ] && [ -f "$file" ] && source "$file";
done;
(hash wal 2>/dev/null && wal -r -t &)
DEFAULT_USER="marcel"
eval $(thefuck --alias)
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
# Vi mode
bindkey -v
# Up/down search for matches of what's already there
autoload -Uz up-line-or-beginning-search down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
bindkey '^P' up-line-or-beginning-search
bindkey '^N' down-line-or-beginning-search
Hmm 🤔
I don't use vi-mode. @ghost @kwinczek could you help guys?
🤦
Plugins are separated by spaces not commas. The plugin line should read:
plugins=(git vi-mode)
i have this exact problem. my . file
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
export RPS1="%{$reset_color%}"
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
ZSH_THEME="spaceship"
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion. Case
# sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment the following line to disable bi-weekly auto-update checks.
# DISABLE_AUTO_UPDATE="true"
# Uncomment the following line to change how often to auto-update (in days).
# export UPDATE_ZSH_DAYS=13
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# The optional three formats: "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# 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)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git zsh-autosuggestions)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh
# export SSH_KEY_PATH="~/.ssh/rsa_id"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
bindkey -v
HISTFILE=50000
SAVEHIST=50000
bindkey -a u undo
bindkey -a '^R' redo
bindkey -a '^?' backward-delete-char
@marco-silva0000 PLEASE add ``` above and below code blocks. The comments in your file are making you scream at people.
i had already, sorry :p
It seems you are not using the zsh vi-mode plugin. You can add it like this:
plugins=(git zsh-autosuggestions vi-mode)
Having the same issue. I am not using oh-my-zsh or prezto or any framework for that matter
Relevant part of .zshrc
# Spaceship
fpath=( "$HOME/.zsh" $fpath )
autoload -U promptinit; promptinit
prompt spaceship
SPACESHIP_TIME_SHOW=true
SPACESHIP_USER_SHOW=false
SPACESHIP_RPROMPT_ORDER=(
time
vi_mode # Vi-mode indicator
)
SPACESHIP_PROMPT_ORDER=(
# user # Username section
dir # Current directory section
git # Git section (git_branch + git_status)
package # Package version
node # Node.js section
golang # Go section
# docker # Docker section
line_sep # Line break
jobs # Background jobs indicator
exit_code # Exit code section
char # Prompt character
)
#Using Vim mode in Zsh
bindkey -v
bindkey '^P' up-history
bindkey '^N' down-history
bindkey '^?' backward-delete-char
bindkey '^h' backward-delete-char
bindkey '^w' backward-kill-word
bindkey '^r' history-incremental-search-backward
Complete .zshrc
# Ensure path arrays do not contain duplicates.
typeset -gU cdpath fpath mailpath path
path=(
/usr/local/{bin,sbin}
/usr/local/go/bin
$GOPATH/bin
$HOME/.bin
$HOME/.bin-large
$path
)
export HIST_STAMPS="dd/mm/yyyy"
export HISTIGNORE=?:pwd:id:uptime:resize:ls:clear:history:cd:?
export HISTCONTROL=ignoredups
HISTFILE=~/.zsh_history
HISTSIZE=50000
SAVEHIST=10000
## History command configuration
setopt extended_history # record timestamp of command in HISTFILE
setopt hist_expire_dups_first # delete duplicates first when HISTFILE size exceeds HISTSIZE
setopt hist_ignore_dups # ignore duplicated commands history list
setopt hist_ignore_space # ignore commands that start with space
setopt hist_verify # show command with history expansion to user before running it
setopt append_history # add commands to HISTFILE in order of execution
setopt share_history # share command history data
setopt histignorespace # remove command lines from the history list when the first character on the line is a space
# setopt correct # Auto correct mistakes
setopt extended_glob # Extended globbing. Allows using regular expressions with *
setopt nocaseglob # Case insensitive globbing
setopt autoparamslash # If a parameter is completed whose content is the name of a directory, then add a trailing slash instead of a space
setopt rcexpandparam # Array expension with parameters
setopt nocheckjobs # Don't warn about running processes when exiting
setopt numericglobsort # Sort filenames numerically when it makes sense
setopt nobeep # No beep
setopt auto_cd # if only directory path is entered, cd there.
setopt noshwordsplit # use zsh style word splitting
setopt auto_pushd
setopt pushd_ignore_dups
setopt pushdminus
setopt auto_menu # show completion menu on successive tab press
export VISUAL='emacsclient'
export PAGER='less'
export GOPATH=${HOME}/Repos/Go
export LESS='-F -g -i -M -R -S -w -X -z-4'
export EDITOR='vim'
#Sourcing climate scripts
source /etc/bash_completion.d/climate_completion
#Sourcing Zsh Plugins
source ~/.zsh_aliases
source ~/.zsh/enhancd/init.sh
ENHANCD_HOOK_AFTER_CD="ls"
ENHANCD_DISABLE_DOT=1
ENHANCD_DISABLE_HOME=1
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.plugin.zsh
ZSH_AUTOSUGGESTION_HIGHLIGHT_STYLE='fg=grey' # die farbe für autosuggestions funktioniert nur, wenn output of "echotc Co" >= 21 ist. ansonsten sollte "TERM=xterm-256color" exportiert werden !!!
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=200
source ~/.zsh/zsh-history-substring-search/zsh-history-substring-search.zsh
source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# source ~/.zsh/zsh-completions/zsh-completions.plugin.zsh
# Spaceship
fpath=( "$HOME/.zsh" $fpath )
autoload -U promptinit; promptinit
prompt spaceship
SPACESHIP_TIME_SHOW=true
SPACESHIP_USER_SHOW=false
SPACESHIP_RPROMPT_ORDER=(
time
vi_mode # Vi-mode indicator
)
SPACESHIP_PROMPT_ORDER=(
# user # Username section
dir # Current directory section
git # Git section (git_branch + git_status)
package # Package version
node # Node.js section
golang # Go section
# docker # Docker section
line_sep # Line break
jobs # Background jobs indicator
exit_code # Exit code section
char # Prompt character
)
#Using Vim mode in Zsh
bindkey -v
bindkey '^P' up-history
bindkey '^N' down-history
bindkey '^?' backward-delete-char
bindkey '^h' backward-delete-char
bindkey '^w' backward-kill-word
bindkey '^r' history-incremental-search-backward
# bind UP and DOWN arrow keys to substring search
zmodload zsh/terminfo
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
bindkey -M vicmd 'k' history-substring-search-up
bindkey -M vicmd 'j' history-substring-search-down
function history {
print -z $( ([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf -e -i +s --reverse --tac --margin=4%,1%,1%,2% --inline-info --header="ENTER to select (but not execute) command. ESC or CTRL+C to quit." --prompt='Enter string to filter history > ' | sed 's/ *[0-9]* *//' )
}
# fkill - kill process using fzf.
# more great examples how fzf can be used: https://github.com/junegunn/fzf/wiki/examples
function fkill {
local pid
pid=$(ps -ef | sed 1d | fzf -e -m -i +s --reverse --tac --margin=4%,1%,1%,2% --inline-info --header="TAB to (un)select. ENTER to kill selected process(es). ESC or CTRL+C to quit." --prompt='Enter string to filter history > ' | awk '{print $2}')
if [ "x$pid" != "x" ]
then
echo $pid | xargs kill -${1:-9}
fi
}
@ibnishak did you find a fix? I am also not using oh-my-zsh and presto.
@zer09 I copied a function from somebody for just the vi_mode, while rest of prompt is by spaceship.
In general, add the following before your autoload -U promptinit; promptinit
function zle-keymap-select() {
zle reset-prompt zle -R
}
zle -N zle-keymap-select
autoload -U colors && colors
function vi_mode_prompt_info() { echo "%{$fg[red]%}${${KEYMAP/vicmd/[% NORMAL]%}/(main|viins)/[% INSERT]%}" }
RPS1='%t $(vi_mode_prompt_info)'
RPS2=$RPS1
Now, as I mentioned, this is a blind copy from dotfiles of somebody. I don't have enough command over zsh to debug this if something goes wrong. However it works for me. What is better, it works alongside spaceship right hand side prompt too. As in, on my RHS, time is shown by spaceship, while vi_mode is shown by the above function.
I was able to work around this by adding the following line somewhere before promptinit:
spaceship_vi_mode_enable
I'm using zprezto and I have the same problem
Most helpful comment
I was able to work around this by adding the following line somewhere before
promptinit: