简体   繁体   English

如何在 VS Code 中使用缩写命令绑定特定的 Emmet 换行?

[英]How to keybind specific Emmet wrap with abbreviation commands in VS Code?

I have been using the Emmet Wrap with Abbreviation recently and am looking for ways to streamline my process.我最近一直在使用带缩写的 Emmet Wrap,并且正在寻找简化流程的方法。 In particular I am looking for a way to add keybinds for particular Warp abbreviations.特别是我正在寻找一种方法来为特定的 Warp 缩写添加键绑定。

The current process is receiving a plain text sheet of content and then adding HTML structure to it (ie: headings, p tags, divs, anchor tags etc.).当前的过程是接收纯文本内容表,然后向其添加 HTML 结构(即:标题、p 标签、div、锚标签等)。 Emmet Wrap with Abbreviations are great for this as I can just select the text I want formatted and use the abbreviation to quickly format it, however it would be better if there is some way to add key binds to commonly used elements. Emmet Wrap with Abbreviations 非常适合这个,因为我可以只 select 我想要格式化的文本并使用缩写来快速格式化它,但是如果有一些方法可以将键绑定添加到常用元素会更好。

Some examples:一些例子:

  • an anchor tag keybind that uses: a[title][target=_blank]一个锚标签键绑定,使用: a[title][target=_blank]
  • an unordered list keybind that uses: ul>li*一个无序列表键绑定,使用: ul>li*

Through looking for keybind info in VS Code I know you can add custom keyboard shortcuts by editing the keybindings.json file in your user settings.通过在 VS Code 中查找键绑定信息,我知道您可以通过在用户设置中编辑keybindings.json文件来添加自定义键盘快捷键。 But, I can't figure out how to activate the Emmet Wrap with Abbreviations shortcut and then auto-fill the specific abbreviation I want to use.但是,我不知道如何激活 Emmet Wrap with Abbreviations 快捷方式,然后自动填写我想使用的特定缩写。
Currently my general binding for Wrap with Abbreviation is:目前我对 Wrap with Abbreviation 的一般绑定是:

{
   "key": "shift+alt+w",
   "command": "editor.emmet.action.wrapWithAbbreviation"
}

How can I add a Keybinding to VS Code, so that when I hit the bound button it runs the Wrap with Abbreviation command with a specific abbreviation?如何将键绑定添加到 VS 代码,以便当我按下绑定按钮时,它会运行带有特定缩写的 Wrap with Abbreviation 命令?

{
    "key": "ctrl+shift+e",
    "command": "editor.emmet.action.wrapWithAbbreviation",
    "when": "editorHasSelection",
    "args": {
        "abbreviation": "li*",
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM