# Autoformatting in VS Code extension

**URL:** <https://discourse.julialang.org/t/autoformatting-in-vs-code-extension/54544>\
**Category:** VS Code\
**Created:** [February 3, 2021, 4:48pm UTC](https://discourse.julialang.org/t/autoformatting-in-vs-code-extension/54544 "2021-02-03T16:48:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![drbenvincent](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/drbenvincent/32/3046_2.png) [@drbenvincent](https://discourse.julialang.org/u/drbenvincent)\
**Post date:** [February 3, 2021, 4:48pm UTC](https://discourse.julialang.org/t/autoformatting-in-vs-code-extension/54544/1 "2021-02-03T16:48:50Z")

</div>

I’m really enjoying getting to grips with Julia, and I’m finding VS Code a very nice way to code with Julia.

I’ve noticed that there is great auto formatting for indenting code in functions or for loops. For example…

 ![Screenshot 2021-02-03 at 16.42.40](https://global.discourse-cdn.com/julialang/original/3X/e/7/e743e2a3e986412603d9543a87bca71de2a8a4fc.png)

But if you try to span line 14 over two lines then you get this by default

 ![Screenshot 2021-02-03 at 16.43.25](https://global.discourse-cdn.com/julialang/original/3X/a/7/a7a6a49fe0157650d4863eab944a4738493752ca.png)  
which is not as satisfying as something like this  
 ![Screenshot 2021-02-03 at 16.44.16](https://global.discourse-cdn.com/julialang/original/3X/2/5/2537f1a5eebd78578738138ba6a704da4c62e5b6.png)

Are there any plans to develop the auto formatting along these lines in the Julia VS Code extension?

EDIT: Hang on, I didn’t realise [Julia for VS Code](https://www.julia-vscode.org) (not what I have?) is different from the [Julia language support extension for VS Code](https://marketplace.visualstudio.com/items?itemName=julialang.language-julia) (what I do have), or is it???

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [February 4, 2021, 9:46am UTC](https://discourse.julialang.org/t/autoformatting-in-vs-code-extension/54544/2 "2021-02-04T09:46:09Z")

</div>

Those are one and the same 🙂  
I don’t think this is on the roadmap atm (or particularly easy to implement, for that matter), but feel free to open an issue over at [GitHub - julia-vscode/julia-vscode: Julia extension for Visual Studio Code](https://github.com/julia-vscode/julia-vscode).

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [February 4, 2021, 11:10am UTC](https://discourse.julialang.org/t/autoformatting-in-vs-code-extension/54544/3 "2021-02-04T11:10:56Z")

</div>

You could also try [JuliaFormatter](https://github.com/domluna/JuliaFormatter.jl), which has more width-sensitive formatting than the formatter used by the VSCode extension. (~~IMO ideally someday the VSCode extension could switch over, ref [https://github.com/julia-vscode/LanguageServer.jl/pull/759](https://github.com/julia-vscode/LanguageServer.jl/pull/759)~~ This is now implemented in VSCode; [see below](https://discourse.julialang.org/t/autoformatting-in-vs-code-extension/54544/6)). You can run JuliaFormatter from the command line, or via another extension, [https://marketplace.visualstudio.com/items?itemName=singularitti.vscode-julia-formatter](https://marketplace.visualstudio.com/items?itemName=singularitti.vscode-julia-formatter).

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [February 4, 2021, 11:16am UTC](https://discourse.julialang.org/t/autoformatting-in-vs-code-extension/54544/4 "2021-02-04T11:16:09Z")

</div>

Yep, we plan to switch to JuliaFormatter once the code churn around the transition to CSTParser 3 has calmed down.

---

<div class="post-metadata">

**Author:** ![drbenvincent](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/drbenvincent/32/3046_2.png) [@drbenvincent](https://discourse.julialang.org/u/drbenvincent)\
**Post date:** [February 4, 2021, 11:18am UTC](https://discourse.julialang.org/t/autoformatting-in-vs-code-extension/54544/5 "2021-02-04T11:18:55Z")

</div>

Nice. I’ll just wait patiently 🙂

Using Julia in VS Code is really nice. Notebooks are fine, and I love the look of Pluto, but my preference is for VS Code at the moment. Fingers crossed it will get more an more fully featured - it should help people jump from things like Matlab or R into Julia 🙂

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [March 21, 2022, 7:35pm UTC](https://discourse.julialang.org/t/autoformatting-in-vs-code-extension/54544/6 "2022-03-21T19:35:44Z")

</div>

> [@ericphanson](#):
>
> IMO ideally someday the VSCode extension could switch over

Just to update this, the Julia VSCode extension now does use JuliaFormatter (since v1.5.0 of the extension). It’s configured by placing a [`.JuliaFormatter.toml` file](https://domluna.github.io/JuliaFormatter.jl/stable/config/) in the workspace, and run just by calling ”[format document](https://code.visualstudio.com/docs/editor/codebasics#_formatting)” in VSCode.
