I have a .envDEV
file name that I use for development environment variables.
And VSCode is not recognizing it as a dotenv
file.
If I change the language mode for the file, it seems to work (the proper styles are applied, 'though the icon won't change). But it goes away whenever I close and re-open the file.
I'm trying to set a custom file association for this, but without success so far.
seetings.json
"files.associations": {
"*.envDEV": "dotenv" // DOES NOT WORK
"*.envDEV": ".env" // DOES NOT WORK
},
Does anybody know how to do this?
Open your settings (CMD + , on a Mac or CTRL + , on Windows) and enter a file association. We can do this with the settings UI or the settings JSON, both are options to edit your settings. Then enter a file association for the .
Once you have opened the folder, click on the Explorer icon on the top left corner of the VSCode (or press Ctrl+Shift+E) to open the explorer panel. In the explorer panel, click on the New File button as shown in the following screenshot: Then simply type in the new file name . env ...
Settings editor# To open the Settings editor, use the following VS Code menu command: On Windows/Linux - File > Preferences > Settings. On macOS - Code > Preferences > Settings.
By default .env
files have a language id of plaintext
, but vscode does something special with it to assign a different icon. The only way I've been able to accomplish what you're asking for is with an icons extension.
The dotenv extension adds syntax highlighting and the dotenv
language id to all your .env
variant files. Pair that with the vscode-icons extensions, and it changes the icon to the gear that the basic .env
file has.
With just the icons extension, you can use the properties
file association and that works as well, just add the following to settings.json
:
"files.associations": {
"*.env": "properties"
}
With the dotenv extension this works:
"files.associations": {
"*.env*": "dotenv" // THIS WORKS NOW
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With