Vim: Delete All Lines Not Matching Pattern
Vim has a neat regex operation for globally deleting matching lines:
:%g/pattern/d
To invert the behavior and delete all lines not matching the pattern, just use
v
instead of g
:
:%v/pattern/d
Vim has a neat regex operation for globally deleting matching lines:
:%g/pattern/d
To invert the behavior and delete all lines not matching the pattern, just use
v
instead of g
:
:%v/pattern/d