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):
example.env
(no syntax highlighting):
What's the best way to get all .env
files syntax highlighted properly in VSCode?
VS Code has a way to manually define the file association of certain extension types.
To do so for .env
files:
Ctrl
+ ,
or File > Preferences > Settings.file asssociation
.Files: Associations
.*.env
and under Value, add properties
.You can also do the same for .env.example
files.
Switching back to your file, you should see the syntax highlighted.