Vim 9 · Searching and replacing

Delete all lines matching a pattern

Delete every line that contains the pattern.

:g/pattern/d

Caution: Check the pattern with a search first. Undo with u if it removes too much.

Official Vim 9 documentation

More searching and replacing commands

All searching and replacing commands · Vim 9 cheatsheet

Was this page helpful?