Skip to content


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.

Popularity: 3% [?]

Related Posts

Posted in Technology.

Tagged with , , , , , .


One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. Loura says

    Good for people to know.