user2477
user2477

Reputation: 997

Is there a quick way to delete an HTML tag pair in vscode?

For example, before:

<div>
    <div>Titles</div>
    <div>Description</div>
</div>

After:

    <div>Titles</div>
    <div>Description</div>

Upvotes: 44

Views: 30669

Answers (2)

Mark
Mark

Reputation: 180649

Just a note that there is an improvement in vscode v1.63 to also (as the OP requested) remove the lines on which the removed tags reside. It works now in the Insiders Build. See

Emmet Remove Tag command improvement

The "Emmet: Remove Tag" command now removes empty lines around tags if they are the only tags on the line. It also now does not take into account empty lines when calculating the amount to reindent the lines.

See release notes: emmet remove tag improvements

<div>                   <- this entire line will be removed sonce only the tag on the line
    <div>Titles</div>
    <div>Description</div>
</div>                  <- this entire line will be removed 

Upvotes: 2

Matt Bierner
Matt Bierner

Reputation: 65175

Use the Emmet: Remove Tag command:

enter image description here

Setup a keybinding for this with editor.emmet.action.removeTag:

{
    "key": "ctrl+shift+k",
    "command": "editor.emmet.action.removeTag"
}

Upvotes: 91

Related Questions