Quickly trigger comments for .html.eex files in VSCode?

The ElixirLS plugin for VSCode has been pretty good, however it just doesn’t seem to provide much support for .html.eex files. I get no autocompletion or automatic formatting.

The most annoying for me, however, is the inability to quickly comment out lines. For embedded Elixir it’s easier as all you need to do is to type a #. However for lines of actual HTML, manually typing out the commenting syntax gets much more annoying.

Is there anybody who got their VSCode to easily comment .html.eex files? Maybe I just didn’t set something up correctly? I noticed that there’s another plugin vscode-elixir, however since there seem to be functionality overlaps/conflicts, I only installed ElixirLS.

Have you enabled emmet in eex files?

"emmet.includeLanguages": {"HTML (Eex)": "html"}

1 Like

@praveenperera is correct. In addition, when I press Ctrl-/ (or Cmd-/ on macOS) in my VSCode I get Elixir commenting and not HTML commenting:



<%# <h1>Hello</h1> %>

Most of the time that works well enough for me. Although if anybody knows how can you trigger HTML comments and not Elixir comments that might be useful in a few cases as well.

Apparently I do have this line in my settings.json and Emmet has always been working, just not the commenting. @dimitarvp did you also install the vscode-elixir plugin or do you only have the ElixirLS plugin.

Yes, I have both vscode-elixir and ElixirLS.

Just as a note, it works in atom, hitting the commenting key will <!-- ... --> html in html area and will prepend # on elixir code in the escaped areas. Atom has the concept of multiple editors types in different sections of a single file though, does vscode not have that concept?

@dimitarvp Installing vscode-elixir indeed enabled the syntax highlighting for .html.eex files. It seems that there are functionality overlaps with both plugins but if things work fine I’ll just go with such a configuration for now.

@OvermindDL1 Yeah I think Emacs and IntelliJ also support both types of commenting. But I currently prefer to use VSCode for my coding in general due to its good support for other languages. I think it’s more of a case of the authors not having time to add such support. I opened issues in the repos but there was no reply.

1 Like