Elixir code formatting in IDE (with Atom set up example)


Today I learned that Elixir has a great feature that allows you to format your code.

Here are a few reasons you may want to do that (borrowed from The Go Blog):

  • easier to write: never worry about minor formatting concerns,

  • easier to read: when all code looks the same you need not mentally convert others' formatting style into something you can understand.

  • easier to maintain: diffs show only the real changes.

  • uncontroversial: never have a debate about spacing or brace position ever again

In fact, you actually want to format your Elixir code as you make it, meaning there is no need to format all of your project's code every time.

The following bash command does it well on a single file:

cd $projectPath && mix format $filePath

Where: $projectPath - full path to your project's root directory; $filePath - full path to a file you're saving

My IDE of choice happened to be Atom and I'll talk briefly on setting it up.

The Process Palette package so far is the best for this task.

My Shell Command field (with variables) in Process Palette looks the following cd {projectPath} && mix format {fileAbsPath}


Vitaly
Platonov

Backend Developer at JetRockets

Explore more of JetRockets