# Formatting difference between VS Code and JuliaFormatter

**URL:** https://discourse.julialang.org/t/formatting-difference-between-vs-code-and-juliaformatter/131910
**Category:** VS Code
**Tags:** question
**Created:** [August 28, 2025, 1:12pm UTC](https://discourse.julialang.org/t/formatting-difference-between-vs-code-and-juliaformatter/131910 "2025-08-28T13:12:50Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![hildebrandecon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hildebrandecon/32/46604_2.png) [@hildebrandecon](https://discourse.julialang.org/u/hildebrandecon)
#### Post date: [August 28, 2025, 1:12pm UTC](https://discourse.julialang.org/t/formatting-difference-between-vs-code-and-juliaformatter/131910/1 "2025-08-28T13:12:50Z")

</div>

Hi,

I noticed that when using **JuliaFormatter v2.1.6** with VS Code and a local project environment (`Project.toml`), there is a difference in how spaces are handled in indexing expressions, even without a `.JuliaFormatter.toml` file. I think the spaces are just an example.

Minimal example:

- Create a folder with `Project.toml` containing:

```toml
[deps]
JuliaFormatter = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
[compat]
JuliaFormatter = "2.1.6"

```

- Instantiate the environment.

- Create `test.jl`:

```julia
data = rand(2, 2, 2)
getindex(data,:,:,1) # here, no spaces around ":"

```

- Save in VS Code with Julia extension → VS Code **automatically adds spaces** :

```julia
getindex(data, :, :, 1)

```

- Format the file using the Julia formatter

```bash
julia --project=. -e 'using JuliaFormatter; format(".", verbose=true)'

```

CLI formatting **removes the extra spaces** and produces:

```julia
getindex(data,:,:,1)

```

**Setup:**

- Julia: 1.10.3 (also tried in other Julia 1.10 version, no 1.11 available right now)
- JuliaFormatter: 2.1.6 (from `Project.toml`)
- VS Code Julia extension: latest stable
- Only a `Project.toml`, `Manifest.toml` and `test.jl` exist in the folder
- VS Code is using the **local project environment**

It seems the VS Code extension **applies its own formatting on save** , independently of JuliaFormatter CLI behavior or `.JuliaFormatter.toml` options. This leads to differences in spacing between VS Code format-on-save and CLI formatting.

Is there any way to discipline this? I have tried using a `.JuliaFormatter.toml` file, didn’t work.

I also posted this as an issue [here](https://github.com/julia-vscode/julia-vscode/issues/3864).

---

<div class="post-metadata">

### Author: ![hildebrandecon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hildebrandecon/32/46604_2.png) [@hildebrandecon](https://discourse.julialang.org/u/hildebrandecon)
#### Post date: [August 28, 2025, 2:31pm UTC](https://discourse.julialang.org/t/formatting-difference-between-vs-code-and-juliaformatter/131910/2 "2025-08-28T14:31:39Z")

</div>

See here for the reason of the bug: [Formatting difference between VS Code and JuliaFormatter · Issue #3864 · julia-vscode/julia-vscode · GitHub](https://github.com/julia-vscode/julia-vscode/issues/3864)

Using JuliaFormatter v1 fixes this issue until VS code upgrades to JuliaFormatter v2.
