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

How do I access the text from my last insert session?

Answer

".

Explanation

The . register contains the text that was last inserted. You can paste it to repeat the last insertion without using the . command.

How it works

  • ". is the last-inserted-text register
  • ".p pastes the last inserted text
  • The register is read-only
  • Updates every time you exit insert mode

Example

You type Hello, World! in insert mode and press <Esc>. Now ".p pastes Hello, World! at any cursor position.

Tips

  • <C-r>. inserts the last insert text while in insert mode
  • The . command also replays the last insert but includes the motion
  • "./ is the last search pattern register
  • ": is the last command-line command register
  • "% contains the current filename

Next

How do you yank a single word into a named register?