Delete Lines Containing a Pattern
Combining the :global and :delete commands allows us to cut down the size of a file rapidly. We can either keep or discard all lines that match a {pattern}.
结合:global和:delete命令可以快速的裁剪文件。我们可以保留或着去掉匹配{pattern}的行。
测试文件如下

Delete Matching Lines
What if we wanted to throw away everything except for the contents of each tag? In this file, the contents of each link appear on a line of their own, while every other line of the file contains either an opening or a closing tag.
So if we can devise a pattern that matches HTML tags, we could use it with the :global command to reject any lines that match the pattern. These commands would do the trick:
如果我们要删除除标签 包含内容之外的其他所有行,我们可以利用:global命令来删除。
/\v\<\/?\w+> :g//d
Show invisibles Tabs and Spaces Whitespace preferences and filetypes
Keep Only Matching Lines
:v/href/d