How to do tag wrapping in VS code?
A quick search on the VSCode marketplace: https://marketplace.visualstudio.com/items/bradgashler.htmltagwrap.
Launch VS Code Quick Open (Ctrl+P)
paste
ext install htmltagwrap
and enterselect HTML
press Alt + W (Option + W for Mac).
Embedded Emmet could do the trick:
- Select text (optional)
- Open command palette (usually Ctrl+Shift+P)
- Execute
Emmet: Wrap with Abbreviation
- Enter a tag
div
(or an abbreviation.wrapper>p
) - 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