Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do tag wrapping in VS code?

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

like image 800
hannes neukermans Avatar asked Oct 20 '16 13:10

hannes neukermans


1 Answers

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.

enter image description here


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
like image 146
Alex Avatar answered Oct 04 '22 09:10

Alex