vimtricks.wiki Concise Vim tricks, one at a time.

How do I paste the text I just typed in insert mode?

Answer

".p

Explanation

The ". register automatically stores the last text you inserted in insert mode. Pressing ".p in normal mode pastes that text wherever your cursor is, letting you reuse your most recent insert without yanking it first.

How it works

  • Every time you enter insert mode and type something before pressing <Esc>, Vim records that text in the ". register (the "insert register")
  • " tells Vim you want to specify a register
  • . is the register name — the dot register, which holds the last inserted text
  • p pastes the register contents after the cursor

This register is read-only and is updated automatically — you never need to set it manually.

Example

You enter insert mode and type Hello, World! then press <Esc>. The buffer looks like:

Hello, World!

Now move to another line and press ".p:

Hello, World!
Hello, World!

The exact text you typed — Hello, World! — was pasted from the . register.

Tips

  • Use <C-r>. in insert mode to paste the last inserted text without leaving insert mode
  • The . register only captures what you typed — if you pasted from a register or used completion, that text may not be fully captured
  • View the register contents with :reg . to see exactly what was stored
  • The related gi command jumps to the last insert position and enters insert mode — useful when you want to continue typing where you left off rather than paste
  • The . register is distinct from the . command (dot repeat) — the register holds the text, while the command replays the entire change including the operator
  • Other useful read-only registers: "% (current filename), ": (last Ex command), "/ (last search pattern), "# (alternate filename)

Next

How do I edit multiple lines at once using multiple cursors in Vim?