I have a large file where I want to copy only portions of the file that match a regex (multiline) pattern. I found somewhere (probably StackOverflow) that I can do this:
:g/z=45117\.1[0-9]\{2}nm\_.\{-}end/y
This pattern found all the entries I was expecting, but the yank operation only yanked the first line of the first match found
What vim magic do I need to yank all lines of all matches of the multi-line pattern?
Add an A with a space to the end of the command:
:g/z=45117\.1[0-9]\{2}nm\_.\{-}end/y A
It yanks the pattern into register a, so you might want to clear it before the command:
:let @a = ''
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With