How do I copy a named register into the system clipboard without yanking again?
Answer
:let @+ = @a
Explanation
If you already have carefully collected text in a named register, re-yanking just to reach the system clipboard is noisy and error-prone. :let @+ = @a copies register a directly into the clipboard register + with no cursor movement and no buffer edits. This is useful in longer editing sessions where register contents are part of your workflow state.
How it works
@areads the content of registera@+is the system clipboard register (when clipboard support is available):let @+ = @aassigns one register value to another
:let @+ = @a
Example
Suppose register a contains a multiline SQL fragment you recorded earlier:
SELECT id, name
FROM users
WHERE active = 1;
After running :let @+ = @a, you can paste that exact text into another application with your OS paste shortcut, without touching the current buffer.
Tips
- Use
:echo has('clipboard')to confirm clipboard support - Replace
+with*on systems where primary selection is preferred - For append behavior, assign with concatenation:
:let @+ .= @a