I have a file whose content could be like the following:
foo1
bar1
foo2
bar2
bar3
I want to delete from the file all the lines matching the pattern ^foo
and put them altogether somewhere else, possibly in a different file, using the p
command.
I've tried using the command :g/^foo/"Ad
supposing each deleted line would be appended to the register a
. However the command doesn't delete anything nor appends anything to the register a
.
What's wrong with the command I used? Store/append to register is not supposed to work inside a global
command?
There are other commands I can use to achieve what I want?