I recently have noticed that entering and then exiting insert mode will move your cursor one space to the left. This is a default behavior of vim, since it still occurs with vim -u NONE -U NONE -N. I found this answer and stackoverflow, but it doesn't really explain why this is default behavior. Why is this default behavior, and should I use I use a workaround like his answer suggests?

If I were to use a workaround, it would look something like this:

inoremap <Esc> <Esc>l

Also, I did try set virtualedit=onemore but that just seems to do what it says on its help page and nothing more.

  • That is what I thought of when I asked this question. The solution to that would just be to move the cursor back if it is on the end of the line in insert mode, and not every time you exit it. Commented Apr 30, 2015 at 23:00
  • vim.fandom.com/wiki/…
    – user26313
    Commented Mar 10, 2022 at 5:07

1 Answer 1


First you should understand that the cursor is between characters in insert mode and on a character in normal mode. This means that when you exit insert mode the cursor needs to move onto a character. (This is more noticeable in gvim or MacVim, where the default insert mode cursor is a pipe instead of a block)

If you enter insert mode with a then hitting <esc> will place the cursor back exactly where it was. When vim exits insert mode, it needs to move the cursor back onto some character. However since appending is indistinguishable from inserting, one of them was chosen as a default. In this case moving left was chosen.

If you changed the default so that <esc> went to the character on the right, people would be complaining that a<esc> was moving the cursor to the right.

  • Related: unix.stackexchange.com/questions/11402/…
    – FDinoff
    Commented May 1, 2015 at 0:43
  • 3
    Ah, that makes sense. Really the only way of avoiding this behavior is to make it so that if you exit from an insert mode started with i that the cursor moves to the right, and if it is started with a it moves to the left. Commented May 1, 2015 at 0:49
  • @EvergreenTree Correct. You could probably add some mappings that create a buffer local variable that say whether you entered with i or a and then check that variable when you exit insert mode. However I don't know what you would want to happen if you entered insert mode with s or c. I'm probably also missing other ways to enter insert mode.
    – FDinoff
    Commented May 1, 2015 at 3:37
  • 3
    "cursor is between characters" is an absurd statement basing on a illusion of a vertical bar cursor which you may personally use. Others may see a block cursor even in Insert mode and that proves where the cursor really is. You enter a character at a position where the cursor is and the following text is just moved forward. No text editor supports granularity/resolution up to anything "in between" characters, does it?
    – bloody
    Commented Dec 30, 2021 at 15:53
  • 1
    "people would be complaining that a<esc> was moving the cursor to the right" that's another subjective statement since a<esc> represents in fact a stable behavior unlike i<esc>. Just try it out by several consecutive a<esc> presses (which does not drift the cursor further and further away) as opposed to i<esc> (which does).
    – bloody
    Commented Dec 30, 2021 at 15:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.