Remove every matching line
:g/^DEBUG/d _
Example
Normal mode. Lines: INFO start, DEBUG cache, INFO ready.
INFO start
DEBUG cache
INFO ready- :g/^DEBUG/p<CR> Preview · DEBUG cache
- :g/^DEBUG/d _<CR> Delete DEBUG cache · saved yank/delete text preserved
INFO start
INFO readyDetails & Vim help
Run a deletion only on lines matching a pattern.
Clear noisy log lines in one command.
The default :global range is the whole buffer. The _ after :delete preserves yank/delete registers; :global still updates the search and substitute patterns.
Try it in Vim
- Run :g/^DEBUG/p first to inspect matching lines.
- Run :g/^DEBUG/d _ to remove those lines.
- Use u if the result is not what you intended.