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

How do I yank text inside delimiters into a specific named register?

Answer

"ayi(

Explanation

Combining named registers with text object motions lets you precisely yank structured content — like function arguments, quoted strings, or bracketed expressions — into specific registers for later use. This is essential for refactoring workflows.

How it works

  • "a — specify register a for the next operation
  • y — yank operator
  • i( — inner parentheses text object (content inside ())
  • The yanked text goes into register a, not the default register

Example

" Yank function arguments into register a
"ayi(

" Yank string content into register s
"syi"

" Yank block content into register b
"byi{
Code: function(arg1, arg2, arg3)
Cursor inside parens, after "ayi(:
Register a: arg1, arg2, arg3

Tips

  • Works with all text objects: i", i', i[, i{, i<, it (tags)
  • Use a( instead of i( to include the delimiters themselves
  • Uppercase register appends: "Ayi( adds to existing register a content
  • Combine with "ap to paste the specific register contents later

Next

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