How to remove many HTML divs + closing tags efficiently in visual studio code?

Viewed 638

After noticing an unnecessary parent container in my HTML, I want to remove all of it in a headache-free and fast way. Below is a sample of what my code looks like. I want to remove the div with class="remove-this-container" and the children within are varied (I want to keep the children).

I understand I can highlight and use ctrl+d to select all the same divs, but how would I remove the closing tag with it as well?

<div class="container">
  <div class="remove-this-container">
    <div class="random-children1"></div>
    <div class="random-children2"></div>
  </div>
</div>

<div class="container">
  <div class="remove-this-container">
    <div class="random-children1"></div>
  </div>
</div>

<div class="container">
  <div class="remove-this-container">
    <div class="random-children1"></div>
    <div class="random-children2"></div>
    <div class="random-children3"></div>
  </div>
</div>
1 Answers

Emmet has a command called Remove Tag

As you mentioned, you can use Ctrl + D to select all the occurrences of the tag you are looking for.

Using the command palette Ctrl + Shift + P, search Emmet: Remove Tag and select it.

That should delete the opening tag, as well as each closing tag for each of your cursors

Related