3

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.

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

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."
1
  • 2
    Better yet: setreg('c', 'Your text here.', 'v'). Assigning to @c can be problematic (for obscure reasons). – Sato Katsura Jun 24 '16 at 6:37

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.