into a buffer?
:global” command to yank all the lines containing the pattern into a register and then paste the contents of the register into the buffer: :let @a=” :g/mypattern/y A The first command, clears the contents of the register “a”. The second command copies all the lines containing “mypattern” into the register “a”. Note that the capital letter “A” is used to append the matched lines. Now you can paste the contents of register “a” to a buffer using “ap command. For more information, read :help :g :help :y :help let-register :help quote_alpha :help put :help registers :help :registers 12.10.