this post was submitted on 29 Jun 2023
2 points (75.0% liked)

Visual Studio Code

93 readers
3 users here now

Everything VS Code

founded 2 years ago
MODERATORS
 

There are a number VS Code extensions that can be used to delete all console lines in an open file. But is there an extension that will highlight all console.log lines as a check before deleting?

Yes I know that one can select "console.log" then use the Command-F2 key combination to select all occurences in the file. Assuming I want to delete them all, I could then use one of the above-mentioned extensions. 'Am hoping to find an extension that will do both.

you are viewing a single comment's thread
view the rest of the comments
[–] breadsmasher 2 points 1 year ago* (last edited 1 year ago)

VSCode supports regex in find and replace (select the star icon when you open find)

Then using this regex pattern will find all occurrences of

 console.log(anything);

Pattern

 console\.log\(.+\);

You can then just do a replace with nothing, and it’ll remove them all. Not exactly what you wanted (an extension) but this works with a clean vscode install out of the box