1

In the past, I had a problem with the diagnostics virtual text not coming back after exiting insert mode. After a few hours of searching I just gave up.

Today I have spend 2 hours trying to get my autocmd to dismiss copilot ghost text when exiting insert mode. (Very annoying to have this text still there) I needed it to execute on InsertLeavePre event.

Found out now that Ctrl c does not trigger the InsertLeave and InsertLeavePre events. https://github.com/neovim/neovim/issues/21563

I have learnt my lesson and will now map <C-c> to <Esc> :)

But all of this comes down to my question. Why? What I'm I missing here?

1 Answer 1

2

I'm not sure if you're going to like this answer because it's a bit circular, but it's so you can leave Insert mode without triggering InsertLeave or abbreviations!

Traditionally Ctrl-C is used for aborting things, so think of it as "aborting" insert mode: it's used when you want Vim to stop insert mode immediately, without doing anything else.

As a side-note, the current lead developer of Vim recommends against mapping <C-C>. It might be better just to get used to using <Esc> or Ctrl-[ instead, if that's something your muscle memory will allow.

2
  • C-c also, for example, cancels repeats when prefixing insert-mode operations with counts. It really is “stop this now.” Just use Esc :)
    – D. Ben Knoble
    Mar 27 at 13:49
  • Thank you for your answers! Make sense for the <C-c> and thus to differentiate the two.
    – NicoAnde
    Mar 27 at 17:18

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.