In the ex linage of editors, one can append to a register(vim)/buffer(ex,vi) by specifying the register name in uppercase. As an example
g/pat/y A
will append every line match pat
to register a
. But if a
already has content, it will need to be cleared first.
How?
In vim, one can do let @a = ''
. But this depends on having a vim compiled with the expression evaluation feature +eval
. One can also do qaq
, to record nothing into a
, but recording is disabled while executing a register, inside mappings or in :normal
, so it does not lend itself to automating.
vi/ex has no let
, and no q
or 'recording' equivalent , so how is buffers(registers) cleared in practical use?
To my disappointment, :0y a
put line 1 in a
, so the only way I can gleam is doing "ay$
on an empty line. (EDIT: Apparently there is a discrepancy in how y$ works on empty lines between vim and vi)
Anything better?
+eval
? If one does any "automating", he certainly should have it. Otherwise, useqaq
interactively.+eval
orq
"ay$
in an nvi does not clear the buffer for me. I suppose the easiest is to restart ex/vi, if you for some reason do not want to use vim."ay$
yanks until newline if the line is not empty, but yanks the newline if it is. What does it do in nvi, is it just a noop?0"ayh