Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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> 
like image 222
user2477 Avatar asked Mar 17 '18 13:03

user2477


People also ask

How do you edit multiple tags in VS code?

In VS code you can hold opt + cmd or ctrl + alt then use the down and up arrows and the line cursor will duplicate to each line at the position you want. You can then type across multiple lines.

How do I get rid of HTML code?

How does it remove the HTML? StripHTML uses a series of PHP functions (such as strip_tags) and some custom made code to remove HTML and ugly formatting. All you have to do is to paste the text, click the button - and voila!


2 Answers

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" } 
like image 102
Matt Bierner Avatar answered Sep 19 '22 06:09

Matt Bierner


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  
like image 26
Mark Avatar answered Sep 19 '22 06:09

Mark