1

So this is in the help page (:h autocmd-events):

|InsertChange|      when typing <Insert> while in Insert or Replace mode

I don't really understand what it means with when typing <Insert>. So I tried it out by adding this into my init.vim file:

autocmd InsertChange <buffer> echo "yes"

then I opened a file and typed some random characters but yes isn't printed out. How is it suppose to work?

EDIT I also looked into the more detailed description of InsertChange:

                            *InsertChange*
InsertChange            When typing <Insert> while in Insert or
                Replace mode.  The |v:insertmode| variable
                indicates the new mode.
                Be careful not to move the cursor or do
                anything else that the user does not expect.

But I still don't understand what <Insert> is supposed to be.

1

InsertChange is called when the type of insert mode changes; that is, if you change from insert to replace mode by pressing the Insert key.

With this:

autocmd InsertChange * :echom 'change to: ' . v:insertmode

Pressing i<Insert><Insert> should give you:

change to: r
change to: i

There is also a "visual replace" mode (which I just learned about!), and pressing gR<Insert><Insert>:

change to: i
change to: v

These are the only cases where this autocmd is triggered, in the ins_insert() function in edit.c

1
  • 2
    Should be mentioned, since OP since asks what <Insert> is, that it is referring to literally the insert key which may or may not exist on your keyboard. Although i normally enters insert mode in vim, it's not the insert key. Also when pressing <insert> twice from normal mode, we end up in replace mode, which is very different from what i does. – Mass Jan 28 at 1:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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