To remove all the lines in vim that contain certain string execute:
:g/string/d
To do the opposite i.e remove the lines that do not contain certain string execute:
:v/string/d
:g/string/d
To do the opposite i.e remove the lines that do not contain certain string execute:
:v/string/d