Vim Recall繁體中文

Remove every matching line

:g/^DEBUG/d _

Example

Normal mode. Lines: INFO start, DEBUG cache, INFO ready.

Before
INFO start
DEBUG cache
INFO ready
  1. :g/^DEBUG/p<CR> Preview · DEBUG cache
  2. :g/^DEBUG/d _<CR> Delete DEBUG cache · saved yank/delete text preserved
After
INFO start
INFO ready
Details & 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

  1. Run :g/^DEBUG/p first to inspect matching lines.
  2. Run :g/^DEBUG/d _ to remove those lines.
  3. Use u if the result is not what you intended.