Is there a default key binding in VSCode to wrap a selection in an HTML tag like the keyboard shortcut Shift+alt+W in Visual studio 2015? I could not find anything similar in documentation or in the default keyboard shortcuts that indicates its availability out of the box.
Asked
Active
Viewed 1.4k times
3 Answers
47
To automate this go to.
File > Preferences > Keyboard Shortcuts
and add this into your keybindings.json (right hand side window)
{
"key": "ctrl+shift+enter",
"command": "editor.emmet.action.wrapWithAbbreviation",
"when": "editorTextFocus && !editorReadonly"
}
You can replace ctrl+shift+enter with your own key combination.
6
you can use this extension: https://github.com/Microsoft/vscode-htmltagwrap
or you can:
- open the Command Palette: Command/Control+Shift+P (⇧⌘P)
- type "wrap", then select "Wrap with abbreviation"
- type the tag you want and press enter

Victor
- 129
- 1
- 7
-
This extension allows redefining the default tag (saves some key strokes for me), e.g., for `
...
` use `"htmltagwrap.tag": "code"` – Fuhrmanator Feb 02 '18 at 15:45 -
As of 2021/1/25, the vscode-htmltagwrap extension was last updated in 2016. I think you'll have better luck with [Emmet](https://code.visualstudio.com/docs/editor/emmet) which is built in to VS Code. See [this sibling answer](https://stackoverflow.com/a/42434314/109618). – David J. Jan 25 '21 at 15:25
1
Or simply search for the HTMLtagwrap extension in VScode, Make selection. Then use Alt + W. Then enter the new tag.

double-beep
- 5,031
- 17
- 33
- 41

Adebola
- 549
- 1
- 7
- 11
-
As of 2021/1/25, the vscode-htmltagwrap extension was last updated in 2016. I think you'll have better luck with [Emmet](https://code.visualstudio.com/docs/editor/emmet) which is built in to VS Code. See [this sibling answer](https://stackoverflow.com/a/42434314/109618). – David J. Jan 25 '21 at 15:26
...
? – Fuhrmanator Feb 02 '18 at 15:38