Adds formatting and syntax highlighting support for env files (.env
) to Visual Studio Code
-
Syntax highlighting
-
Folding
The extension will enable folding on file content that are wrapped with the following pattern:
# ... << begin with comment(s) ... ... << folded content ... << end with a blank line
-
Formatting
Use the
Format Document
command (CTRL+SHIFT+I) from theCommand Pallete
(CTRL+SHIFT+P) to format the current env file
The extension support env files with the following name:
.env
.env.sample
.env.example
To enable support for other env files with specific naming convention/ file extension, use the files.associations
settings in Visual Studio Code.
For example, the following settings will enable support for *.env.development
and *.env.production
files:
"files.associations": {
"*.env.development": "env",
"*.env.production": "env"
}
-
Highlighting/ Formatting/ Folding doesn't work
Other extensions (like shell-format) could also provides contributions to env files (
.env
). When two or more extensions providing contributions to a same file, there's a chance the contributions of previous extension will be overwritten by the later (see: github.com/microsoft/vscode-docs/issues/2862).To workaround this issue, use Visual Studio Code
files.associations
to force the language of.env
files to be always specified asenv
:Other non permanent solution is by using the
Select Language Mode
button on the Visual Studio Code status bar and set the language toEnvironment Variables
(alias ofenv
) on the opened file:
This project is licensed under the terms of the MIT license.