Alan Rezende

Vim Syntax Highlighting For .env Files

  April 11, 2023
Updated on April 14, 2023
  April 11, 2023
Updated on April 14, 2023

Related to:: Vim

In order to enable syntax highlighting for .env files on Vim, 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