Do sed-like delete commands in vim

Son*_*ton 1 vim

I'm comfortable doing search/replace in vim, but how do I delete all lines in a file (or between certain lines) if they match a condition? Currently I shell out and run a sed command, for example:

sed -i '/^CRITICAL/d' hosts
Run Code Online (Sandbox Code Playgroud)

(delete all the lines that start with CRITICAL from the hosts file).

How would I do this in vim?

ojs*_*ojs 6

我想最好的方法是使用ex命令g.

:g/^CRITICAL/d
Run Code Online (Sandbox Code Playgroud)

和你的 sed 命令一样。