How I Speed up my HTML editing by 50% with Emmet in Visual Studio Code?

Want to Speed up your HTML editing? If yes then this is right blog for you. In this blog, I will explore about Emmet which I have been using in Visual Studio Code by which you can save your precious development time while working on HTML Code.

What is Emmet?

Writing HTML tags are too boring and repetitive tasks. Wish we could have something which can do it on behalf of developers.
Luckily, we have Emmet. To demonstrate the benefits of Emmet, I will use Visual Studio Code which is a free and open source code editor given by Microsoft. 
Emmet is mainly used to speed up coding in HTML, CSS and XML. Emmet permits you to compose huge HTML code blocks at very high speed utilizing CSS selectors. Emmet offers extremely unique tool that can enormously improve your editing experience in HTML.
Some of the Emmet actions are listed below –
  • Expand Abbreviation – Expand the abbreviation into correct HTML, CSS or XML code.
  • Match Tag Pair – It is a tag balancing which matches the closing of any HTML tags.
  • Wrap with Abbreviation- It intelligently wraps the selected content.
  • Toggle Comment- Like any other editor feature this is one of the common feature to Toggle comment.
  • Merge Lines- It merges multiple selected lines into one.
Emmet 2.0 supports all the major actions.  
 
So, if you are an Angular developer then Emmet is very helpful for you. Because it will help you to write template (.html) file quickly. 

Do we need to install a extension to work with Emmet in Visual Studio Code?

No any extensions require to work with Emmet in Visual Studio Code.

How to Work with Emmet Abbreviation to speed up HTML?

By default Emmet Abbreviation is enabled for HTML, XML, CSS, SASS, LESS. When you start typing, you may notice the abbreviation displayed related to what you have typed. 
 
If you want to exclude a language for which Emmet Abbreviation should not work, then you can write below code in settings.json file. In below array, you can add the languages for which you want to exclude Emmet Abbreviation.
  {
"emmet.excludeLanguages": [


]
}

If you want Tab key to work with Emmet then add below line in settings.

"emmet.triggerExpansionOnTab": true

Emmet Abbreviation Demo

Let’s understand the benefits of Emmet with multiple demo. 
Open Visual Studio Code and add a new HTML file. The very first thing I will do is that, just type ! (Exclamation mark) and you will notice that Emmet Abbreviation appears. (As shown in below picture)
Click on Emmet Abbreviation or press tab from your keyboard and complete HTML structure will be available on your page. See, how much time you have saved.
 

 

Let’s think about another situation. Suppose you want to write <p> tag 10 times. How will Emmet help in this?
 
Very simple. Type p*10 and press tab from the keyword. You will see that paragraphs tag has been created 10 time. Think about the time you saved.
Simply write below line and press tab.
 div#id$*10>a.click

You will se below output in your HTML page.

 

 

If you want to create a table structure with 50 rows and 5 columns then write below line and press tab.
table>tr*50>td*5

These extensions can be understand better with a demonstration, to demonstrate the same I have created a short video for you. Please watch this video and use these extensions. This video shows few extensions as well, you can ignore that one and focus on Emmet Abbreviation only.

 

Emmet works well with CSS edition also. Open a CSS file. 

Go to any class written in the CSS file. To give margin 10 px, just type m10. To give padding 10px, just type p10. To set display property to none, just type dn and press tab.

Emmet is one of the most important web developer features in available in Visual Studio Code.

Hope this blog is helpful for your development experience.

Leave a Comment

RSS
YouTube
YouTube
Instagram