VSCode - 在“<mark></mark>"中包装选定的文本; [英] VSCode - wrap selected text in &quot;&lt;mark&gt;&lt;/mark&gt;&quot;

查看:27
本文介绍了VSCode - 在“<mark></mark>"中包装选定的文本;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 VSCode 中使用 Markdown 预览器,并希望能够突出显示.md"文件中的某些文本并将其包装在" 标签,以便在您查看呈现格式的 Markdown 文件时突出显示.

I'm using the markdown previewer in VSCode and would like the ability to highlight some text in an ".md" file and wrap it in a "<mark></mark>" tag so that it displays highlighted when you view the markdown file in its rendered format.

有没有一种快速简便的方法来做到这一点?

Is there a quick and easy way to do this?

推荐答案

一个片段应该可以解决问题.

A snippet should do the trick.

"wrap_mark": {
    "prefix": "wrap_mark",
    "body": [
        "<mark>$TM_SELECTED_TEXT</mark>"
    ],
    "description": "Wrap selected with <mark>"
},

将其添加到您的代码段/markdown.json 文件中.

Add that to your snippets/markdown.json file.

然后,将以下内容添加到 keybindings.json 文件中

Then, add the following to your keybindings.json file

{ "key": "cmd+e 1", 
    "command": "editor.action.insertSnippet", 
    "args": { "name": "wrap_mark" } 
},

现在,在你的 Markdown 文件中,你可以突出显示文本并点击 cmd + e 然后 1 突出显示的文本被包裹在 <代码><标记>

Now, in your markdown file you can highlight the text and hit cmd + e then 1 and the highlighted text gets wrapped in <mark>

我有一系列映射到 cmd + e + "" 的片段 - 你可以使用任何你想要的组合键(我在 Mac 上,所以我使用cmd 键)

I have a series of snippets mapped to cmd + e + "" - you can use any key combo you want (I'm on a Mac so I use the cmd key)

这篇关于VSCode - 在“<mark></mark>"中包装选定的文本;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆