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

How do I view the contents of all registers in Vim?

Answer

:registers

Explanation

The :registers command displays the contents of all Vim registers, showing you exactly what text is stored in each one. This is essential for managing yanked and deleted text, especially when working with named registers.

How it works

  • :registers (or :reg for short) opens a list of all registers and their contents
  • Each register is identified by a single character: " (unnamed), 0-9 (numbered), a-z (named), and several special registers
  • The display shows the register name, its type (character, line, or block), and the stored text

Key registers explained

  • "" — the unnamed register, filled by y, d, c, s, and x
  • "0 — the yank register, filled only by y commands (not deletes)
  • "1-"9numbered registers, a history of recent deletes (1 is most recent)
  • "a-"znamed registers, explicitly set by the user with commands like "ayy
  • "+ — the system clipboard register
  • "* — the primary selection register (X11 systems)
  • "/ — the last search pattern
  • ". — the last inserted text
  • ": — the last Ex command
  • "% — the current file name

Example

After yanking a line with yy and deleting a word with dw, running :reg might show:

""   some word
"0   The full yanked line
"1   some word
"%   main.go

Tips

  • Use :reg a b c to view only specific registers instead of all of them
  • Use "0p to paste from the yank register when the unnamed register has been overwritten by a delete
  • In insert mode, press <C-r> followed by a register name to insert its contents
  • Use :reg + to quickly check what is on your system clipboard

Next

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