Simple patterns to do useful things with the Ex Mode :global command in Vim

Delete all lines that match a pattern (help pattern)

:g/pattern/d
:global/pattern/delete

Delete all lines that don’t match a pattern (help :vglobal)

:g!/pattern/d
:v/pattern/d
:vglobal/pattern/delete

Remove all trailing whitespace with :substitute

:%s/\s\+$//e

Find more info by running help :global and help :substitute