7

I am using VSC for developing html pages. It's been a great experience using emmet with VSC, but often I find in a situation where I have to wrap a set of elements with a div, but have to use emmet on a single line and then cut paste the end tag at the end of the set of elements I want to map.

Is there any way where I can use emmet and automatically wrap the output of emmet around a set of selected elements?

2 Answers2

28

Try the Emmet: Wrap with Abbreviation command:

enter image description here

Matt Bierner
  • 58,117
  • 21
  • 175
  • 206
  • 4
    If you need wrapping each line by a tag, just add the * as a sufix to the tag. ie: 1. Select lines 2. Select Emmet Wrap Individual Lines with Abbreviation 3. Type in command "li*" – Jimmy Oct 27 '20 at 21:15
6

The easiest way is to use a key binding, you can assign your own key for this. file > preference > keyboard shortcuts > editkeybindings and assign your own

[{ "key": "ctrl+shift+g", "command":"editor.emmet.action.wrapWithAbbreviation", "when": "editorTextFocus && !editorReadonly" }]
Shamseer Ahammed
  • 1,787
  • 2
  • 20
  • 25