How to Delete Entire Lines Containing String in VSCode's Search (Find in Files)

How can we delete entire lines containing some substring in VSCode’s Search: Find in Files function?

Example scenario in VSCode

Suppose we have hundreds of files containing the line date: xxxx-xx-xx, where xxxx-xx-xx is a different date in every file.

We want to delete this entire line from every file, but we can’t directly search for each string.

Use regular expressions remove entire lines

Let’s fix this issue using regular expressions.

All the keyboard shortcuts are for Windows.

  1. Open VSCode’s Search: Find in Files (Ctrl+Shift+F)
  2. Use regular expressions (.* button or Alt+R)
  3. Write the regular expression: ^.*[STRING].*$\n, where [STRING] is your substring
    1. In our scenario: ^.*date.*$\n
  4. Replace with empty line
  5. Profit