Let's say I have opened many files on Vim with vim file1 file2 file3
... And their content is like the following:
file1:
random content
random content
stringThatMatchesRegex
random content
file2:
random content
random content
random content
file3:
stringThatMatchesRegex
random content
random content
random content
Considering I could have n
files opened like that, I'd like to find a way of closing all files that match stringThatMatchesRegex
, so I'd like to close undesirable files with a regular expresssion. In this example, only file2
would remain open. I know I could close single files using :bd
on Vim, but I have no idea how to implement this if
condition. Is it possible? Can I close files that have a line or lines that match a regular expression?
not_me
, you could dovim `find . -type f -exec grep -qvs 'not_me' {} \; -print`