Sort Lines in Vim Alphabetically for Elixir aliases and Credo

Credo complains if aliases are not sorted alphabetically. Here's a quick tip on how to sort them in Vim
Sort Lines in Vim Alphabetically for Elixir aliases and Credo

As a long time developer using vim, I have no plans to try another editor.

After working with credo for a while and needing to sort aliases alphabetically, I found that this feature is built into vim.

Let’s imagine you have these aliases:

alias Lancr.Client.Google.Contacts
alias SomeOtherModule
alias Goth.Token
alias GoogleApi.People.V1.Connection

Rather than needing to focus in on alphabetizing the aliases manually to satisfy Credo, select the modules with Shift + V.

Then you can enter :sort to envoke the sort function.

alias GoogleApi.People.V1.Connection
alias Goth.Token
alias Lancr.Client.Google.Contacts
alias SomeOtherModule

This is a real time-saver when you have many files to process.

I plan on doing a follow-up for a complete Vim setup for developing Elixir.

Troy Martin
Senior Engineer working with Elixir and JS.
Keep in the Loop

Subscribe for Updates