Removing the rest of the line when the pattern does not occur is ... so that I can understand.
Did you mean delete the entire line if it does not have a template?
:v/pattern/d
If you had in mind, keep the string, but collect the characters:
:v/pattern/s/.*//
Digitaloss
source share