Is there a way to preload a named register in vim?

For example: I would like to have an empty comment always available in register "c". This way I could insert it and quickly add the text.

  • Im assuming if this capability is available it would happen in .vimrc or similar. Jun 23, 2016 at 19:49
  • 3
    "Buffer" or "register"?
    – romainl
    Jun 23, 2016 at 19:51
  • oops... named registers, like a-z (I will edit the post - thanks) Jun 23, 2016 at 19:57

2 Answers 2


You can edit the contents of any register in vimscript by using "@" before the letter and then using it like a variable.

let @c="Your text here."
  • 2
    Better yet: setreg('c', 'Your text here.', 'v'). Assigning to @c can be problematic (for obscure reasons). Jun 24, 2016 at 6:37

Use the setreg function in your .vimrc:

call setreg("register-name", "text")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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