vim delete all lines not matching pattern

I’ll memorize the g/... syntax someday.

:g!/pattern/d

I can just look for the pattern as usual with /pattern and tweak it live, then do

:g!//d

and it will atke the last used pattern.