How do you delete lines with certain keywords in VScode

Visual Studio-CodeVscode Settings

Visual Studio-Code Problem Overview


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.

Visual Studio-Code Solutions


Solution 1 - Visual Studio-Code

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPapaLazarouView Question on Stackoverflow
Solution 1 - Visual Studio-CodeMarkView Answer on Stackoverflow