How do I yank a visual selection to a specific named register?
Answer
"ayv
Explanation
Using named registers with visual mode lets you store multiple independent snippets simultaneously. By prefixing the yank command with "a through "z, you can save selections to specific registers and paste them back independently, enabling advanced multi-clipboard workflows.
How it works
"a— specify registerafor the next operationy— yank the visual selection into that register"ap— paste from registera- Uppercase register (
"Ay) appends to registerainstead of replacing
Example
" Select and yank function name to register f
viww"fy
" Select and yank argument list to register a
vi("ay
" Now paste either one independently
"fp " pastes function name
"ap " pastes argument list
Registers:
"f: myFunction
"a: arg1, arg2, arg3
Tips
- Use
"Ay(uppercase A) to append to a register — great for collecting text from multiple places - Check register contents with
:registersor:reg a - Registers persist across edits, so you can yank several things before pasting
- Use
"_dto delete into the black hole register (avoiding overwriting your yanked text)