, , , , , ,

1. Show all the lines that match a pattern, say PATTERN

Use “g!” or “v” for negative matching. For example, to show all the lines that DO NOT match the pattern, PATTERN, use

2. Delete all the lines that contain the pattern, PATTERN

Again, g! or v may be used for negative matching.

Application: You may use any of the following two commands to delete all the blank lines (including lines containing only whitespaces) from a file

Reference: Vim Wiki.