Get all commands in history matching pattern
q:
gets the history of all commands. From there, it’s just
:%g/pattern/yank A
%g
runs on all lines matching pattern. yank A
appends to register A. If you do yank a
instead, it will only save the last matching line.