Elixir and VS Code


There are a plethora of code editors to choose from. Almost all of them can be extended with third-party plugins, custom styling, and keybindings. Sublime is popular, as is VS Code, Atom and Brackets. Many professional developers suggest using Vim, or gVim if you're on a Mac. Unfortunately, Vim lacks sensible defaults and is practically unusable "out-of-the-box". Despite being a powerful editor that has won the hearts and minds of developers over the past few decades, it's not user friendly and requires an investment of time just to operate.

Ultimately, choosing an editor is based on personal preference. You should try two or three of the options mentioned until finding the one that's most comfortable. In my opinion, the best free code editor is VS Code. It offers a robust solution with a light weight feeling. It has the widest built-in feature set, there are many third-party extensions, it's easy to learn and customize. It also boots up quickly, a feature that's important to me. Here is a screenshot of the Visual Studio Code editor.

Oooh, fancy!

  1. The file explorer in the top left shows both the currently open files (open editors) and the project directory (elixir_tips)
  2. This is the main workspace. Notice the syntax highlighting
  3. A mini-map is located along the right hand side. This is useful for quickly navigating around large files
  4. A built in terminal sits at the bottom
  5. Github integration can be accessed from here

This is just a broad overview of the UI. As you can see there are many other useful icons for debugging, running code, searching files, splitting the screen, and much more. Visual Studio code is consistently being developed. There are often new releases with improvements and fixes. Let's check out some of the Elixir specific extensions.

Here I have two Elixir-specific extensions shown, "vscode-elixir" and "vs-code-elixir-formatter". The formatter is new to Elixir and comes with Elixir 1.6+. It automatically formats Elixir code on "save". It corrects the spacing, fixes indentation, and adds parenthesis to remove ambiguity. Another extension worth mentioning is ElixirLS. It provides a fantastic feature set including code completion, dialyzer analysis, debugging support, automatic closing of code blocks, and more. One feature I enjoy is when a new dependency is added to the mix file, it will automatically fetch the dependency on "save". This saves me from having to run mix deps.get each time I want to add a new dependency. In order to perform its duties, it automatically adds a hidden folder ./elixir_ls to the root directory of each Elixir project. It's a good idea to add the folder to .gitignore to keep superfluous development files out of your repository.

results matching ""

    No results matching ""