Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Ok, so I finally made the great change. In my .zshenv, I changed my EDITOR:

export EDITOR=vim

There are a couple of questions I have that are so minor that I didn't want to start separate questions for them. Here they are:

  1. How do I get zsh to distinguish between insert mode and command mode like in vim? Preferably this would change the cursor from an underline to a block like in vim, but displaying text at the bottom would work as well.

  2. How do I get it to act more like vim? For instance, I'd rather it be in command mode by default and not go out of it after one command.

share|improve this question
// , Have you been getting any weird behavior with command-line edits? I've been running into the ~ character getting inserted when I press the Delete key in zsh. I asked a question about it here:… – Nathan Basanese Nov 8 '15 at 4:46
up vote 19 down vote accepted

1.) (see and ):

function zle-line-init zle-keymap-select {
    RPS1="${${KEYMAP/vicmd/-- NORMAL --}/(main|viins)/-- INSERT --}"
    zle reset-prompt
zle -N zle-line-init
zle -N zle-keymap-select


2.) i suspect that you have to write another zsh-widget to do that, get inspired by the first of the two links for the first problem.

share|improve this answer

akira's solution has the following problem when using multiline prompts: when going from ins to cmd mode, the prompt redraw causes few lines to be deleted from the previous output (and the new prompt is displayed few lines above). How many lines depends on how many lines you have in your prompt.

The way to deal with that is to use zle-line-finish, without using zle reset-prompt there. An example:


function zle-keymap-select {
  zle reset-prompt
zle -N zle-keymap-select

function zle-line-finish {
zle -N zle-line-finish

And then you can add it to your right-prompt, for example:


This is straight from my blog post about it:

share|improve this answer
This answer should get a lot of votes. This is the first time I've seen this solution, and it works where the others don't. I spent an hour fiddling around with the zle-line-init widget to no avail. Changed it to match what Pawel provided and bingo! – Colin R Nov 28 '12 at 5:34
Thanks! It still isn't 100% bulletproof - from time to time I experience a situation where some lines from my previous output are deleted - but it happens so rarely that I just ignore it. – Paweł Gościcki Nov 28 '12 at 10:06
RPROMPT2 should be set as well so that the status is displayed in continuation lines. Also, when using this you may want to do setopt transient_rprompt so that modes for previously accepted lines aren't displayed. – qqx Mar 24 '13 at 15:59
Thanks @qqx! Those are very cool tips! – Paweł Gościcki Mar 24 '13 at 20:19
@cheflo you can see my current version of this setup here: -- maybe that will help you – Paweł Gościcki Feb 24 at 8:29
zle-line-init() { zle -K vicmd; }
zle -N zle-line-init

these two lines make sure it starts in command mode

share|improve this answer
Does not work, zsh starts in insert mode anyway – baldrs Jan 15 at 13:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .