In that case you can run the following command, replacing the path with the path to rebar3 on your machine, or can go to the directory where rebar3 is located and run as. Mine was at ~/.asdf/installs/elixir/1.10.4-otp-23/.mix/rebar3 as I use asdf for version management. If you already have Elixir installed, chances are that there is a rebar3 binary somewhere in that installation.
(Note: the erlang extension also tries to format Erlang code, but it wasn’t working for me, and it doesn’t have any setting to set the desired formatter).įollowing were the steps I used to make it work (all the settings and instructions can be found at Github READMEs of Erlang Formatter for VSCode and rebar3_format, and the Getting Started Page of rebar3, but I’m trying to make it a tiny bit less confusing than how I found it). Visual Studio Code’s extension called Erlang Formatter uses these formatters to format Erlang code on save or when the shortcut keys combination is pressed which is Shift + Alt + F on Windows, Shift + Option + F on Mac and Ctrl + Shift + I on Linux.
There are 3 main formatters for Erlang which you can use from the command-line,