Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 670
Nick Law Avatar asked Mar 21 '18 03:03

Nick Law


People also ask

How do you delete a whole line in VSCode?

In order to quickly delete a line in VSCode, you can simply press Ctrl+Shift+K keyboard combination while the cursor is being placed in the desired line. The hotkey can be changed by modifying editor.

How do you select an entire line of code?

Ctrl + L on Windows or Command + L on Mac to select the whole line in VS Code.

How do you delete lines with certain keywords in VSCode?

Ctrl + Shift + K for delete line. You can also fire the replace with an empty field, instead of using a keyboard combination. It works fine also.


1 Answers

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.

like image 115
Hongzhi WANG Avatar answered Sep 29 '22 15:09

Hongzhi WANG