Using elm-format in Visual Studio Code
elm-format is a great tool that formats your Elm code. It makes code easier to read by forcing the same formatting rules for all Elm developers. The rules are defined by the official Elm Style Guide.
In this post, I will show how to integrate the
elm-format with the Visual Studio Code.
Here’s an example of how
elm-format changes formatting of the code:
You can integrate it with your code editor or run it separately. It supports popular code editors, so go on and check for the editor of your choice.
elm-format with Visual Studio Code
If you are using the Visual Studio Code as an editor, you need to install elm extension from the marketplace. It adds Elm syntax support and it supports
I recommend to automatically format your Elm code on saving, so you’d never need to manually format it.
To automatically format code on each file save, you can add the following line to the settings:
Settings can be accessed via menu
Settings. You can add this setting globally or to a current workspace.
You can install
elm-format as the
Here are examples of running it with various options:
This might be useful if you’ve got a team working on an Elm project. You can add
elm-format to your project building pipeline to ensure a uniform formatting.