Search code examples
webstorm

Supporting of syntax highlighting of .env


I am using WebStorm 2021.3.1.

There is a question on .env file, since it seems like it's not supporting the syntax highlighting, commenting etc. for .env, but it supports .env.* like .env.example.

How do I get .env supported? Below are screenshots for .env and .env.local

Below is screenshot for .env enter image description here

Below is screenshot for .env.local enter image description here


Solution

  • Go to Settings/Preferences | Editor | File Types, locate Text file type there. Based on your first screenshot you should have .env entry there.

    • If you have it: remove it and re-add it to the .env file file type where it should be in the first place.

    • If there is no such entry under Text, add .env pattern directly to the .env file file type. If such pattern is already assigned to some another file type then the IDE will give you a prompt asking to remove it from another file type.

    How .env file file type should look by default:

    enter image description here