如何同时在VS Code中运行两个“查找和替换”?

huangapple go评论56阅读模式
英文:

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

问题

我正在使用Markdown,我意识到我希望我的部分是粗体。

如果我在元素上运行查找和替换:

<空格>`<unique_code_snippet>`<空格>

并替换所有实例:

<空格>`

与:

<空格>`**

这不起作用,因为代码变成了:

<空格`**<unique_code_snippet>`**<空格>

这围绕着元素变成了:

**`<空格>

我能否以一个VS-Code的查找和替换操作来访问这两个实例:

<空格>`和`<空格>

并替换为:

<空格>'**<unique_code_snippet>**'<空格>

我可以通过两个“查找和替换”操作来实现这一点,但我宁愿不这样做。

英文:

I am working in Markdown and I realised I am looking for my &lt;code&gt; sections to be in bold.

If I run Find and Replace on the element:

&lt;space&gt;`&lt;unique_code_snippet&gt;`&lt;space&gt;

and replace all instances of:

&lt;space&gt;`

with:

&lt;space&gt;`**

This does not work because the code becomes:

&lt;space`**&lt;unique_code_snippet&gt;`**&lt;space&gt;

That surrounds a &lt;code&gt; element to become:

**`&lt;space&gt;

Is there a way I can access both instances of

&lt;space&gt;`&lt;and&gt;`&lt;space&gt;

and replace with:

&lt;space&gt;&#39;**&lt;unique_code_snippet&gt;**&#39;&lt;space&gt;

In one Find and Replace action in VS-Code?

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

答案1

得分: 0

Here are the translated parts:

使用正则表达式搜索和替换

  • 查找:&lt;space&gt;(`&lt;unique_code_snippet&gt;`)&lt;space&gt;
  • 替换:&lt;space&gt;**$1**&lt;space&gt;

如果您想一次性替换所有代码部分为粗体版本

  • 查找:&lt;space&gt;(`[^`]+`)&lt;space&gt;
  • 替换:&lt;space&gt;**$1**&lt;space&gt;
英文:

use regex search and replace

  • find: &lt;space&gt;(`&lt;unique_code_snippet&gt;`)&lt;space&gt;
  • replace: &lt;space&gt;**$1**&lt;space&gt;

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

  • find: &lt;space&gt;(`[^`]+`)&lt;space&gt;
  • replace: &lt;space&gt;**$1**&lt;space&gt;

huangapple
  • 本文由 发表于 2023年6月4日 23:33:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76401148.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定