How do I re-insert the exact same text I typed during my last insert mode session?
Answer
<C-a> in insert mode
Explanation
Pressing <C-a> while in insert mode inserts the same text that was typed during the previous insert mode session. Vim stores the last inserted text in the dot register (.), and <C-a> replays it directly — no need to escape, use ., and re-enter insert mode. This is particularly useful when you need the same literal text repeated in multiple non-adjacent locations within a single insert session or across successive inserts.
How it works
<C-a>— in insert mode, replays the contents of the.register (last inserted text) at the current cursor position<C-@>— identical to<C-a>, but also exits insert mode and returns to normal mode afterward (likei<C-a><Esc>in one keystroke)- The dot register holds what you typed since entering insert mode last time, including backspaces and special characters
Example
You are in insert mode and have just added a repeated pattern at the end of one line. You move to the next line (using <C-o>j to stay in a single insert session) and want to add the same text:
const FOO_TIMEOUT = 5000; ← just typed FOO_TIMEOUT
const BAR_TIMEOUT = 5000; ← cursor here
Instead of typing 5000 again, press <C-a> to insert the last typed text.
Tips
<C-r>.also inserts the last inserted text (via register name), but<C-a>is faster as a two-key chord- Use
<C-@>when you want to replay and immediately return to normal mode - The dot register is also accessible via
<C-r>.in command-line mode for Ex commands <C-a>only replays text — it does not replay cursor movements or ex commands