In VIM, one of the features I always manage to forget exists is the `g` ex command.

Recently I had the need to delete all lines in a file containing a certain pattern. Using the `g` ex command, this sort of task is a breeze:

``````:g/pattern/d
``````

This will delete all lines in your document containing `pattern`. You can then extend on this by using a regular expression as the pattern:

``````:g/^\[DEBUG\]/d
``````

Which will result in all lines starting with `[DEBUG]` being deleted. This can be very useful for clearing up log files for simple analysis.

For a more in-depth look at the `g` ex command checkout the VIM Wiki article.