How to do tag wrapping in VS code?

后端 未结 7 1366
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-04 05:10

I would like to wrap my selected html within a tag in VS code. How do I do that?

7条回答
  •  失恋的感觉
    2020-12-04 05:53

    Embedded Emmet could do the trick:

    1. Select text (optional)
    2. Open command palette (usually Ctrl+Shift+P)
    3. Execute Emmet: Wrap with Abbreviation
    4. Enter a tag div (or an abbreviation .wrapper>p)
    5. Hit Enter

    Command can be assigned to a keybinding.


    This thing even supports passing arguments:

    {
        "key": "ctrl+shift+9",
        "command": "editor.emmet.action.wrapWithAbbreviation",
        "when": "editorHasSelection",
        "args": {
            "abbreviation": "span"
        }
    },
    

    Use it like this:

    • span.myCssClass
    • span#myCssId
    • b
    • b.myCssClass

提交回复
热议问题