Search code examples
visual-studio-codemarkdowntext-editor

How do I run two "Find and Replace" at once in VS-Code?


I am working in Markdown and I realised I am looking for my <code> sections to be in bold.

If I run Find and Replace on the element:

<space>`<unique_code_snippet>`<space>

and replace all instances of:

<space>`

with:

<space>`**

This does not work because the code becomes:

<space`**<unique_code_snippet>`**<space>

That surrounds a <code> element to become:

**`<space>

Is there a way I can access both instances of

<space>`<and>`<space>

and replace with:

<space>'**<unique_code_snippet>**'<space>

In one Find and Replace action in VS-Code?

I could do this with TWO Find and Replace actions, but I'd rather not


Solution

  • use regex search and replace

    • find: <space>(`<unique_code_snippet>`)<space>
    • replace: <space>**$1**<space>

    If you want to replace ALL code sections with bold versions in one go

    • find: <space>(`[^`]+`)<space>
    • replace: <space>**$1**<space>