How do I select and copy a specific portion of multiple lines?

Take this example text

X = 'x',
YY = 'yy',
ZZZ = 'zzz,

I want to copy just the text after the = of each of these lines, all at once i.e.

'x',
'yy',
'zzz',

How would I do this? I know how I’d set up a macro that I could repeat on each line to copy the text after =, but I’m not sure how to do this all at once so all of the contents ends up yanked.

Do a qaq to clear the a register, then smack it with a :%g/\v^.*=/norm! 0f'"Ay$. You’ll also want to make sure > is in your :h 'cpoptions'.

This puts it into your a register, so a pa will suffice to get it.

for short stuff like this i would just align it enough so that you could do a block select and yank instead of typing out regex magic which will likely have bugs and require a few attempts.

in a worst case where you had a million lines of this, i believe there are alignment plugins so you could aligned what you need on the = and then block select.

I mean the regex isn’t that complicated and was only there since I can’t see the whole file, you can just as well do qaq then :%norm! 0f'"Ay$ which has no regex.

If you have only those lines you can do:

:%norm 02f "Ay$