You could delete the lines in a register:
First clean up your register q
for example with qqq
in normal mode.
Then use :g/PATTERN/norm! "Qdd
In normal mode when you use "qdd
you replace the content of the q
register with the deleted text but if you use "Qdd
you append the deleted text to the register.
EDIT As @Matt pointed out in the comments you don't need to use the norm!
trick in you global command because :d
also accepts a register as a parameter (:h :d
) so you can simply use
:g/PATTERN/d Q
You can then use "qp
to past the content of the register where your want to.
Another solution is to combine :h :move
with the global command. For example to move all the matching lines at the end of the buffer:
:g/PATTERN/move $