Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Key binding to wrap a selection with an html tag in VSCode

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.

like image 664
bobbyK12 Avatar asked May 24 '16 18:05

bobbyK12


People also ask

How do you wrap code in VS Code?

wordWrap": "on" You can toggle word wrap for the VS Code session with ⌥Z (Windows, Linux Alt+Z).

How do I get the html structure in VS Code shortcut?

Go to the Extensions view (Ctrl+Shift+X) and type 'html' to see a list of relevant extensions to help with creating and editing HTML.


2 Answers

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.

like image 106
Zgr3doo Avatar answered Sep 19 '22 21:09

Zgr3doo


you can use this extension: https://github.com/Microsoft/vscode-htmltagwrap

or you can:

  1. open the Command Palette: Command/Control+Shift+P (⇧⌘P)
  2. type "wrap", then select "Wrap with abbreviation"
  3. type the tag you want and press enter
like image 27
Victor Avatar answered Sep 21 '22 21:09

Victor