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

How do I inspect the current contents of a specific register before pasting or running it as a macro?

Answer

:reg {name}

Explanation

The :reg {name} command displays the current contents of one or more named registers in a formatted listing. This is essential when debugging macros, verifying clipboard contents before pasting, or confirming that a yank captured what you intended.

How it works

  • :reg — displays all non-empty registers
  • :reg {name} — displays only the register(s) you specify, e.g. :reg q or :reg abc
  • Output shows the register name, type indicator (c for characterwise, l for linewise, b for blockwise), and the stored text
  • Special characters like <CR> and <NL> are rendered symbolically so you can read macro sequences

Example

After recording a macro with qq, running:

:reg q

Shows something like:

Type Name Content
  c  "q   ^[jdd

Where ^[ represents <Esc>. This lets you verify the macro captured the right sequence before running @q.

Tips

  • Inspect multiple registers at once: :reg abq shows registers a, b, and q together
  • Use :reg " to check the unnamed register (last yanked or deleted text)
  • If a macro is producing unexpected results, :reg {name} is the fastest way to see what was actually recorded
  • Combine with :let @q = ... to programmatically fix a macro after inspection

Next

How do I inspect a Vim register's full details including its type (charwise, linewise, or blockwise) in Vimscript?