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. – Matt May 12 '20 at 11:06+eval
orq
– aktivb May 12 '20 at 11:12"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. – Christian Brabandt May 12 '20 at 11:36"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? – aktivb May 12 '20 at 11:590"ayh
– Matt May 12 '20 at 13:10