24

I want to auto closing the html code in the html.erb file.
What should I do?


Added screenshots


enter image description here
COLEAN
  • 665
  • 2
  • 9
  • 24

3 Answers3

49
  1. Install the Ruby extension.
  2. Add this to your user settings:

    "emmet.includeLanguages": {"erb": "html"}
    

Example with erb and ruby:

VSCode User Settings

bryanlo22
  • 591
  • 6
  • 6
  • That way, auto closing works for html code in .html.erb, but it does not work for ruby ​​code. Is there any way I can use both? – COLEAN Apr 01 '18 at 08:42
  • Sure, you can add this to your user settings: `"emmet.includeLanguages": {"erb": "html", "ruby": "html"}` – bryanlo22 Apr 01 '18 at 17:18
  • im sorry I set the following in `emmet.includeLanguages` :: `"files.associations": { "erb": "html", "ruby": "html" }` But still html code in .html.erb does not auto close – COLEAN Apr 03 '18 at 08:29
  • It looks like a screenshot but still does not auto close Results modified the post – COLEAN Apr 03 '18 at 15:39
  • @bryanlo22 Why not ```"emmet.includeLanguages": {"html.erb": "html"```? What's the difference between that and ```"emmet.includeLanguages": {"erb": "html"}```? –  Apr 02 '20 at 14:57
22

You don't need to install any extension, just add this to you User settings.json file in VSCode at the end of the file, and it will work like a charm.

"emmet.showSuggestionsAsSnippets": true,
"emmet.includeLanguages": {"html.erb": "html", "erb": "html"}

More info about emmet suggestion ordering

Mihai Chelaru
  • 7,614
  • 14
  • 45
  • 51
meenachinmay
  • 389
  • 2
  • 6
7

Install Auto Close Tag Extension

html.erb file is included by default

Toh
  • 131
  • 4