#elixir

TILFebruary 20, 2019by Vitaly Platonov

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}

TILJanuary 12, 2019by Dmitry Voronov

Manage Elixir versions like RVM & Rbenv

You can install different versions of the Elixir with help of Kiex, like in Ruby with a RVM and Rbenv.

Download and install Kiex


\curl -sSL https://raw.githubusercontent.com/taylor/kiex/master/install | bash -s

```bash



In .bashrc (or .zshrc if you use z shell), add the following

```bash

[[ -s "$HOME/.kiex/scripts/kiex" ]] && source "$HOME/.kiex/scripts/kiex"

```bash



Install required Elixir 

```bash

kiex install 1.7 # or another version

```bash



And then you can use any version

```bash

kiex use 1.7

```bash