Question

Visual Studio Code - find and remove entire line

I have ~150 files that I need to remove the jQuery import from, as we have Webpack importing it automatically.

How can I achieve this with find and replace in vscode? I would like to remove a single line from each file and have the rest of the code shift up a line. I have the below regex, however, I'm not sure what I need to put in the replace field to remove the line.

enter image description here

 46  53279  46
1 Jan 1970

Solution

 87

Try add \n to your search regex and replace with empty string.

In your case: ^import \$ from 'jquery';$\n


Update: November 2018 (version 1.30)

Multiline search input

Last month, we added support for multiline search. This month we improved the search UX to make it easier to use. Now, you can search with multiline text without having to write a regular expression. Type Shift+Enter in the search box to insert a newline, and the search box will grow to show your full multiline query. You can also copy and paste a multiline selection from the editor into the search box.

2018-11-13

Solution

 12

As an update, let's say I need to delete deployStage: 3 from the next block of code and also be sure I don't let the blank space:

  score:
    deployStage: 3
    ports:
      - container: 1000
        portName: tcp
    imagePullPolicy: IfNotPresent

I need this regex: ^.*deployStage.*[0-9]\n as this:

enter image description here

The result is this:

  score:
    ports:
      - container: 1000
        portName: tcp
    imagePullPolicy: IfNotPresent
2022-01-20