How does Ctrl+C differ from Escape when exiting insert mode, and why does it matter?
Answer
<C-c>
Explanation
<C-c> exits insert mode immediately but silently skips two important side effects that <Esc> (and its equivalent <C-[>) always trigger: abbreviation expansion and InsertLeave autocommands.
How it works
| Behavior | <Esc> |
<C-c> |
|---|---|---|
| Exits insert mode | ✓ | ✓ |
| Expands abbreviations | ✓ | ✗ |
Fires InsertLeave autocmds |
✓ | ✗ |
| Interrupts pending operator | ✓ | ✓ |
Example
If you have an abbreviation and an autocommand:
iabbrev teh the
autocmd InsertLeave * echo 'left insert'
Type: teh<Esc> → expands to "the", echo fires
Type: teh<C-c> → stays as "teh", echo does NOT fire
Tips
- If you remap
<C-c>to<Esc>(:inoremap <C-c> <Esc>) you get full<Esc>behaviour including autocommand firing - Plugin authors rely on
InsertLeavefor features like auto-formatting on save, LSP signature hiding, and copilot dismissal — using<C-c>to exit insert will bypass these - Use
<Esc>or<C-[>for clean insert-mode exits; reserve<C-c>for interrupting a runaway operation