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 qor:reg abc- Output shows the register name, type indicator (
cfor characterwise,lfor linewise,bfor 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 abqshows registersa,b, andqtogether - 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