Use regex replace in vscode find

Published on April 07, 2021

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
The vscode find popup

Here it is as code.

// for the find

// for the replace
Darragh ORiordan

Hi! I'm Darragh ORiordan.

I live and work in Sydney, Australia enjoying the mountains and the ocean.

I build and support happy teams that create high quality software for the web.

Contact me on Twitter!

Sign up for the newsletter

Get new writings, curated tech articles and coding tips!

Read the Privacy Policy.