How do I copy the contents of one register to another?
Answer
:let @b = @a
Explanation
The :let @b = @a command copies the contents of register a into register b. This is useful for preserving register content before operations that might overwrite it.
How it works
:let @b = @acopies registerato registerb:let @+ = @0copies the yank register to the clipboard:let @a = @a . @bconcatenates two registers
Example
Preserve your yank before a complex operation:
:let @z = @0 " Save yank register to z
" ... perform operations that modify registers ...
"zp " Paste the preserved text
Tips
@syntax accesses registers in Vimscript:let @/ = 'pattern'sets the search pattern:let @" = @+copies clipboard to default register- This works with all register types
- Useful in scripts and complex editing workflows