21

I already know that you can copy something to the a register using: (plus a yank, delete, etc. command)

"a

I also understand that you can append to the a register using:

"A

In addition I understand how to copy something to the clipboard register using:

"+

What do I type to append to the clipboard register?

My vim version:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan 2 2014 19:39:59) Huge version with GTK2 GUI.
10

There is no normal mode command for that but you can simply append to another register and :let the clipboard register to the content of that register:

"Ay
"Ay
"Ay
:let @+ = @A
  • 1
    Would I put that let in my .vimrc file? – Jason Basanese Jul 4 '15 at 21:24
  • 3
    Please note that let @+ = @A discards the type of register a. The correct way to copy registers is something like this: call setreg('+', getreg('a', 1, 1), getregtype('a')). – Sato Katsura Jul 5 '15 at 6:51
  • // , Does this actually append though? – Nathan Basanese Dec 29 '15 at 18:19
  • // , Why do you list three "Ay commands? – Nathan Basanese Dec 29 '15 at 18:20
  • It could have been four or twelve. Just an example. – romainl Dec 29 '15 at 19:35
7

You can call setreg('+', lines, 'a'), but as far as I can tell there is no way to do that with normal mode commands. You have to use one of the upper case letter registers for that.

  • Just using :let @+ .= 'XXX' seems to work? – Martin Tournoij Jul 4 '15 at 6:56
  • 7
    @Carpetsmoker Yes and no. There has been a recent discussion about it on vim_dev and apparently you aren't supposed to do that, even though it may appear to work under some conditions. I presume it has to do with the register contents having a type (character / line / block), and string concatenation not doing the necessary bookkeeping. It doesn't make any difference anyway, it still isn't a normal mode command. – lcd047 Jul 4 '15 at 7:02

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.