Vim Syntax Highlighting For .env Files

Apr 14, 2023

Related to:: Vim - Mod MD

In order to enable syntax highlighting for .env files, you can set the filetype to sh (bash script), as the syntax used in .env files is similar to the syntax used in .sh files.

While normal .env files are (or at least should be) automatically recognized by VIM, you may want to use the sh filetype for files like .env.backup or .env.example to ensure consistent highlighting.

This is especially helpful for developers working with multiple .env files.

set filetype=sh

Graph View