Does any kind of :call yank(register_name, "string") API exist in vim? Or at least :yank register_name "strings" - I can't find any way to yank in vimscript without modifying a VIM buffer.

  • Are you talking about registers or buffers?
    – romainl
    Commented Apr 3, 2023 at 5:28
  • @romainl buffers
    – minseong
    Commented Apr 3, 2023 at 11:57
  • Not sure how buffers are involved, here.
    – romainl
    Commented Apr 3, 2023 at 13:24
  • @JoL yeah, that sort of makes sense but also not really. Color me puzzled.
    – romainl
    Commented Apr 3, 2023 at 13:43
  • @romainl because the only way I know how to yank text is to put it in a buffer and then use y or :yank
    – minseong
    Commented Apr 3, 2023 at 14:13

1 Answer 1


:help setreg()

It's precisely :call setreg(register_name, "string")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.