How do I return to normal mode from absolutely any mode in Vim?
Answer
<C-\><C-n>
Explanation
While <Esc> works to leave insert or visual mode, it does not work in every situation — particularly in terminal mode (:terminal), where <Esc> is consumed by the running program. The key sequence <C-\><C-n> is Vim's universal escape: it returns you to normal mode from any mode, including insert, visual, command-line, terminal-job, and operator-pending modes.
How it works
<C-\><C-n>— unconditionally switches to normal mode regardless of the current mode- Unlike
<Esc>, this sequence is never intercepted by terminal programs or custom mappings - It is the only reliable way to exit terminal-job mode without configuring a custom mapping
Example
You open a terminal inside Vim with :terminal. You are now in terminal-job mode, and pressing <Esc> sends the escape key to the shell. To get back to normal mode:
" Press Ctrl-\ then Ctrl-n
<C-\><C-n>
You are now in terminal-normal mode and can navigate, yank text, switch windows, or close the buffer.
A common mapping to make this more ergonomic:
tnoremap <Esc> <C-\><C-n>
Tips
- Essential for Neovim users who work with the built-in terminal emulator frequently
- Useful in Vimscript and mappings where you need a mode-agnostic way to ensure you are in normal mode before executing commands
- Works identically in both Vim and Neovim