VSCode formatter not working

I made this function with a long signature:

function foo(Aₙₘ::AbstractMatrix{Float64}, Eₙₘ::AbstractMatrix{Float64}, JAₙₘ::AbstractMatrix{Float64}, JEₙₘ::AbstractMatrix{Float64}, mn::Int, dn::Int, Cₙ::AbstractVector{Float64}, xₙ::AbstractVector{Float64}, Δxₙ::AbstractVector{Float64})
    println("Hi")
end

I’m using VSCode with Julia extension. I’m still not very familiar with both, but if I do: Ctrl + Shift + P and then Format Document With ... > Julia, nothing happens.

image

These are my workspace settings:

{
    "julia.cellDelimiters": [
        "^#(\\s?)%%",
        "^#-"
    ],
    "editor.formatOnSave": false,
    "[julia]": {
        "editor.defaultFormatter": "julialang.language-julia"
    }
}

Any idea about what can I do? Thanks!

This may be because your code is already formatted.

You can try modifying the code to

function foo(  Aₙₘ::AbstractMatrix{Float64},   Eₙₘ::AbstractMatrix{Float64}, JAₙₘ::AbstractMatrix{Float64}, JEₙₘ::AbstractMatrix{Float64}, mn::Int, dn::Int, Cₙ::AbstractVector{Float64}, xₙ::AbstractVector{Float64}, Δxₙ::AbstractVector{Float64})
            println("Hi")
end

and then try again to see if it works.

Thanks for your response. That works, it removes unnecessary whitespaces, but I was expecting the long line to be splitted (like black formatter in python).

Sure. Create a new file in your project’s root directory and name it

.JuliaFormatter.toml

Then simply paste the following text into it.

# See https://domluna.github.io/JuliaFormatter.jl/stable/ for a list of options
margin = 100

I see, just having that file but empty is enough to use default values. Thanks!

1 Like