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

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 = @a copies register a to register b
  • :let @+ = @0 copies the yank register to the clipboard
  • :let @a = @a . @b concatenates 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

Next

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