How do you delete lines with certain keywords in VScode

I have this regular expression to find certain keywords on a line:

.*(word1|word2|word3).*

In the find and replace feature of the latest VSCode it works ok and finds the words but it just blanks the lines leaving big gaps in-between.

I would like to delete the entire line including linefeed.

The find and replace feature doesnt seem to support reg exp in the replace field.

48196 次浏览

If you want to delete the entire line make your regex find the entire line and include the linefeed as well. Something like:

^.*(word1|word2|word3).*\n?

Then ALT-Enter will select all lines that match and Delete will eliminate them including the lines they occupied.