Remove All Lines Containing String in VSCode
How do we delete entire lines containing a certain substring in VSCode with the Find
function?
Example Scenerio in VSCode
I had a JSON file where I wanted to delete every line containing the line code
where every value of code
was different.
Using regex and VSCode Find in File function.
- Open VSCode’s
Search: Find in Files
. (cmd+f) - Click on the regular expression button
[.*]
- Write the regular expression
^.*[STRING].*$\n
, where[STRING]
is your substring. It would be^.*code.*$\n
in our example scenario - Replace all with an empty line.