More vim

Ok, so another adventure today… the story begins with a MySQL dump of a Drupal database, and inserts so large they span more than a screen. This ended with me wishing for a less cluttered dump, say, with only the “INSERT INTO …” statements left in the file.

From a thread I recently read on, I’d gotten some new insights into how to do stuff, which was taken even further today when I sought out how to find all lines not containing some string (i.e. “INSERT INTO”) and remove it:


will find all lines containing “FOO”. Similarly,


will find all lines beginning with ” FOO”. Now to the cool parts:


will find us all lines NOT containing “FOO”.

And finally:


will delete all lines NOT containing “FOO”.


Tags: , , ,

Comments are closed.