# ECTO\_EDITOR with Visual Studio Code

**URL:** <https://forum.elixirforum.com/t/ecto-editor-with-visual-studio-code/44381>\
**Category:** Discussions\
**Tags:** ecto, ecto\_sql, ecto-migration\
**Created:** [December 9, 2021, 7:57pm UTC](https://forum.elixirforum.com/t/ecto-editor-with-visual-studio-code/44381 "2021-12-09T19:57:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![brentjanderson](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/brentjanderson/32/13120_2.png) [@brentjanderson](https://forum.elixirforum.com/u/brentjanderson)\
**Post date:** [December 9, 2021, 7:57pm UTC](https://forum.elixirforum.com/t/ecto-editor-with-visual-studio-code/44381/1 "2021-12-09T19:57:27Z")

</div>

ECTO\_EDITOR is a cool feature within ecto\_sql. [From the docs](https://hexdocs.pm/ecto_sql/Mix.Tasks.Ecto.Gen.Migration.html):

> This generator will automatically open the generated file if you have ECTO\_EDITOR set in your environment variable.

Until now, I hadn’t gotten it to work. But, researching for this post I figured it out. If you add the following to your `.bashrc` or `.zshrc` file, Ecto will conveniently open your editor for you:

```elixir
export ECTO_EDITOR="code -rg"
# the -r flag tells it to reuse the current window
# the -g flag tells it to go to the line number specified

```

This assumes you have installed VS Code’s CLI tool on your PATH.  
For Mac, look here: [Installing Visual Studio Code on macOS](https://code.visualstudio.com/docs/setup/mac)  
For other platforms, I think it’s automatically set up for you.

Hopefully this helps someone else that’s looking to fine tune their Ecto + VS Code integration!

---

<div class="post-metadata">

**Author:** ![cpgo](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/cpgo/32/25792_2.png) [@cpgo](https://forum.elixirforum.com/u/cpgo)\
**Post date:** [December 9, 2021, 8:22pm UTC](https://forum.elixirforum.com/t/ecto-editor-with-visual-studio-code/44381/2 "2021-12-09T20:22:28Z")

</div>

There is also `PLUG_EDITOR`

> **[Link Phoenix debug page stack trace to your editor | Angelika.me](https://angelika.me/2020/03/22/link-phoenix-debug-page-stack-trace-to-your-editor/)**
>
> You can configure Plug.Debugger to generate links that open the line that caused the error in your editor.
