Skip to content
Shuai YUAN edited this page May 29, 2015 · 1 revision

Table of Contents

Tip 98: Delete Lines Containing a Pattern

Return to the top: <>

On the Etymology of Grep

abbreviated form of the `:global` command:

  • `re`: regular expression
  • `p`: `:print`

Delete Matching Lines with `:g/re/d`

Example: throw away everything except for the contents of each `` tag:

Keep Only Matching Lines with `:v/re/d`

Example: Delete each line that doesn’t contain `href`:

Table of Contents


Clone this wiki locally