PracticalVim Tip98 - yszheda/wiki GitHub Wiki

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`:

⚠️ **GitHub.com Fallback** ⚠️