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

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 register a for the next operation
  • y — yank the visual selection into that register
  • "ap — paste from register a
  • Uppercase register ("Ay) appends to register a instead 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 :registers or :reg a
  • Registers persist across edits, so you can yank several things before pasting
  • Use "_d to delete into the black hole register (avoiding overwriting your yanked text)

Next

How do I return to normal mode from absolutely any mode in Vim?