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

How do you set a register programmatically in Vim?

Answer

:call setreg('a', 'text')

Explanation

Use setreg() to set register contents from Vimscript. The third argument controls type: v (characterwise), V (linewise), <C-v> (blockwise).

Next

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