Use regex replace in vscode find

Photo by Adi Goldstein on Unsplash

I needed to replace text that was a bit specific and to use vscode's regex replace but had to figure out the syntax. Just making a note here for myself so it's easy to lookup again!

If you're replacing text in a wrapped element you need to use groups and then replace the first item.

The example below will replace html comments with JSX code comment wrapping. Handy for converting raw tailwindui components to react components!

The vscode find popup

Here it is as code.

// for the find
{/*(.*)*/}

// for the replace
{/$0/}

Hey! Are you a developer?

🚀 Set Up Your Dev Environment in Minutes, Not Hours!

Tired of spending hours setting up a new development machine? I used to be, too—until I automated the entire process!

Now, I just run a single script, grab a coffee, and let my setup take care of itself.

Save 30+ hours configuring a new Mac or Windows (WSL) development environment.
Ensure consistency across all your machines.
Eliminate tedious setup and get coding faster!
Get Instant Access →