Wrapper HTMLInstall the extension from here Developed ByDemo Videohttps://github.com/user-attachments/assets/8dc17ec9-7bf7-4803-b850-2b9e524fbc60 FeaturesWrapper HTML wraps, unwraps and renames HTML and JSX tags while keeping your indentation tidy. Closing tags are always handled for you. Wrap with Tag (
|
| You select | What gets wrapped |
|---|---|
world in <p>Hello world</p> |
Just world |
div in <div class="box"> (e.g. by double-clicking it) |
The whole <div class="box">…</div> element |
Part of an attribute, like class="box" |
The whole element |
div in a closing </div> |
The whole element |
From the middle of one <li> to the middle of the next |
Both <li> elements, complete |
- Pick a common tag from the list, or type any tag Emmet-style:
| You type | You get |
|---|---|
section |
<section> |
div.card.wide#main |
<div id="main" class="card wide"> |
.wrapper |
<div class="wrapper"> |
button[type=submit disabled] |
<button type="submit" disabled> |
a[href="/docs" target=_blank] |
<a href="/docs" target="_blank"> |
my-element |
<my-element> |
- Your recently used tags appear at the top of the list.
- Multi-line content is placed on its own lines and indented one level, using your editor's tab/space settings.
Remove Tag (Unwrap)
Removes the element around the cursor and keeps its content, outdenting it to fit.
Rename Tag
Renames the element around the cursor, updating the opening and closing tags together.
JSX, Vue and Svelte
- In
.jsx/.tsxfiles, classes are written asclassName, and<>wraps in a fragment. - Tag matching understands
{expressions}in attributes, comments,<script>/<style>blocks, self-closing and void elements (<br>,<img>).
Usage
- Keyboard:
Ctrl+1wraps (Ctrl+Cmd+W/⌃⌘Won macOS, whereCtrl+1switches desktops). Unwrap and Rename have no default shortcut, so you can bind keys you like (see below). - Right-click menu: in HTML, JSX, Vue, Svelte, Astro, PHP and other template files, right-click → Wrapper HTML.
- Command Palette:
Ctrl+Shift+P/Cmd+Shift+P, then typeWrapper HTML.
Keyboard shortcuts
| Command | Windows / Linux | macOS |
|---|---|---|
| Wrap with Tag | Ctrl+1 |
Ctrl+Cmd+W (⌃⌘W) |
| Remove Tag (Unwrap) | not set | not set |
| Rename Tag | not set | not set |
Only Wrap has a default shortcut. Below is how to set or change any of them.
Option 1: the Keyboard Shortcuts editor (any OS)
- Open Keyboard Shortcuts:
- Windows / Linux:
Ctrl+KthenCtrl+S, or File → Preferences → Keyboard Shortcuts - macOS:
Cmd+KthenCmd+S, or Code → Settings → Keyboard Shortcuts
- Windows / Linux:
- Search for
Wrapper HTML. - Double-click a command, press the keys you want, then press
Enter.
If the keys are already used by something else, VS Code lists it under the command. Right-click it and choose Show Same Keybindings.
Option 2: keybindings.json
Open the Command Palette (Ctrl+Shift+P on Windows / Linux, Cmd+Shift+P on macOS) and run Preferences: Open Keyboard Shortcuts (JSON). The file lives here:
| OS | Location |
|---|---|
| Windows | %APPDATA%\Code\User\keybindings.json |
| macOS | ~/Library/Application Support/Code/User/keybindings.json |
| Linux | ~/.config/Code/User/keybindings.json |
Add the entries for your OS inside the [ ]. "when": "editorTextFocus" means the shortcut only works while you are typing in an editor, so it won't affect the terminal or other panels.
macOS
[
{ "key": "ctrl+cmd+w", "command": "html-wrapper.wrapper", "when": "editorTextFocus" },
{ "key": "ctrl+cmd+u", "command": "html-wrapper.unwrap", "when": "editorTextFocus" },
{ "key": "ctrl+cmd+r", "command": "html-wrapper.rename", "when": "editorTextFocus" }
]
Windows
[
{ "key": "ctrl+1", "command": "html-wrapper.wrapper", "when": "editorTextFocus" },
{ "key": "ctrl+alt+u", "command": "html-wrapper.unwrap", "when": "editorTextFocus" },
{ "key": "ctrl+alt+r", "command": "html-wrapper.rename", "when": "editorTextFocus" }
]
Linux
[
{ "key": "ctrl+1", "command": "html-wrapper.wrapper", "when": "editorTextFocus" },
{ "key": "ctrl+alt+u", "command": "html-wrapper.unwrap", "when": "editorTextFocus" },
{ "key": "ctrl+alt+r", "command": "html-wrapper.rename", "when": "editorTextFocus" }
]
These are suggestions. Any keys work as long as they don't clash with something you use.
Wrap with a fixed tag, skipping the picker (any OS, change the key to suit):
{ "key": "ctrl+alt+d", "command": "html-wrapper.wrapper", "args": { "tag": "div.container" }, "when": "editorTextFocus" }
Rename straight to a given tag:
{ "key": "ctrl+alt+s", "command": "html-wrapper.rename", "args": { "name": "section" }, "when": "editorTextFocus" }
To turn off the default Wrap shortcut, add the same entry with a - in front of the command, e.g. { "key": "ctrl+1", "command": "-html-wrapper.wrapper" }.
Shortcut conflicts by OS
- macOS:
Ctrl+1switches to Desktop 1 when System Settings → Keyboard → Keyboard Shortcuts → Mission Control → Switch to Desktop 1 is on, which is why the default on macOS is⌃⌘W. Window managers such as Rectangle use manyCtrl+Optionshortcuts, soCtrl+Cmdis usually safer. - Windows: on some keyboard layouts (German, Polish, etc.),
Ctrl+Altworks likeAltGr, which types special characters. If aCtrl+Altshortcut stops you typing a character, pickCtrl+Shift+Altinstead. - Linux: desktops such as GNOME and KDE reserve some
Ctrl+Altkeys (for exampleCtrl+Alt+Topens a terminal andCtrl+Alt+arrowsswitch workspaces). If a shortcut does nothing in VS Code, check your desktop's keyboard settings. - Settings Sync: VS Code keeps keybindings separate per OS by default, so a Mac setup won't overwrite your Windows or Linux shortcuts.
Release Notes
v2.1.0
- Type any tag as an Emmet-style abbreviation (
div.card#main,button[type=submit]) - New Remove Tag (Unwrap) and Rename Tag commands
- Recently used tags appear first in the picker
- JSX support:
classNameand<>fragments - Right-click menu entry in HTML and template files
- Reliable tag matching across lines, comments, scripts, quoted attributes and JSX expressions
- Fixed: a selection is now wrapped as selected, instead of wrapping the surrounding element
- Selections never split a tag: selecting a tag name (e.g. double-clicking
div) wraps the whole element, and partial selections grow to include complete elements - Fixed: indented elements are no longer over-indented, and your editor's indentation settings are respected
v2.0.1
- Added smart indentation support for better code formatting
- Improved tag matching for nested HTML structures
- Added support for HTML attributes (like href for anchor tags)
- Enhanced error handling and user feedback
- Better handling of long documents and complex HTML structures
- Improved formatting preservation for both single-line and multi-line content
Installation
Open Visual Studio Code. In the Extension Store search wrapper html. or download it from here https://marketplace.visualstudio.com/items?itemName=Spikey.wrapper-html
if the keys are conflicting then change them as given below: Go to the "View" menu and select "Command Palette" (or use the shortcut Ctrl+Shift+P or Cmd+Shift+P on macOS). Type "Preferences: Open Keyboard Shortcuts (JSON)" and select it from the dropdown. In the keybindings.json file, add your custom key binding as shown above. Enjoy your streamlined HTML wrapping experience!