2

I wanted to yank all matching lines of a buffer in a give register. I choose "A

:g/<match>/y A

did this trick for me.I guess

"Ap

is the command to paste A's content, I got my matching lines plus older lines as well, tried clearing A using

:let @A=''

but still able to paste using "Ap .What am I doing wrong?

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Oct 16 2013 20:39:23)
MS-Windows 64-bit GUI version with OLE support
Included patches: 1-52
Tripp Kinetics
  • 4,960
  • 2
  • 21
  • 34
Logan
  • 174
  • 9

2 Answers2

7
:let @a=''

a is the real name of the register

A is just a way of appending to a

:let @A=''

appends nothing to register a i.e. has no effect (this explanation added later)

:let @A='fred'      appends fred to a
:let @A=@b          appends register b to register a
zzapper
  • 4,003
  • 5
  • 44
  • 41
  • yes, this did it. "real name" argument makes sense too. So why did ViM not issue error/warning? does it treat A as one more variable? – Logan Jun 05 '14 at 15:42
  • 2
    Don't know but the sad thing is there's no way to append to the * paste register. you have to do :let @*=@a – zzapper Jun 05 '14 at 15:51
5

you should do

 let @a=''

usually when I need clear a reg, I do qaq, I feel it is easier to type.

Kent
  • 173,042
  • 30
  • 210
  • 270