skip to Main Content

VSCode being strange about environment files. Even though it shows the correct file icon for the example.env as a dotenv file in the file view/tab, only .env is syntax-highlighted correctly when opening the file.

.env (correct):

enter image description here

example.env (no syntax highlighting):

enter image description here

What’s the best way to get all .env files syntax highlighted properly in VSCode?

2

Answers


  1. I guess vscode env formetter extension is build to get highlights all files starting with ".env" not anything before the name in your case "example.env". I guess it is treating a separate language file which definations is not installed.
    If you want to have separate env for local and production you can name them as ".env.local" for local and ".env" for production. Vscode will hightlights syntax for these.

    Login or Signup to reply.
  2. I use the extension DotENV. Works flawlessly for me.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search