Geekness – closer to the world

Geeky at the Lake of Zurich

vim: Regex Search and Delete Line

:%g!/\< \(STRING\|VALUE\)\>/d

Explanation
:%g Range to search. %g means the complete file
! Negotiation. Can be used to negate the regex
\< \(STRING\|VALUE\)\ regular expression (regex). Can be anything
/d command to execute with each line found. d means delete

Example used
:%g/INSERT INTO `table` VALUES>/d

This command deletes ALL lines with INSERT INTO `table` VALUES from the current file.

One thought on “vim: Regex Search and Delete Line

Comments are closed.