Help! Does anyone know how to use JuliaFormatter in VSCode editor?

Help! Does anyone know how to use JuliaFormatter in VSCode editor?

I have installed JuliaFormater in VS Code editor but I don’t have a clue how to use it to format my Julia source code.

Can anyone give me some instructions?

Regards

The docs would be a good place to start. Do you have the Julia extension installed in vs code? Seems like it uses JuliaFormatter.jl to do it’s formatting, so all you need to do in vs code is call the format command (see docs or do Ctrl-Shift-P to open the command menu).

1 Like

Okay. I will give CTRL-Shift-P a try.

No it is not working.

I wrote

function main(a,b)
c=a+b
end

and then I press CTRL-SHIFT-P but nothing changes

then I press COMMAND-A to select everything and then CTRL-SHIFT-P but nothing changes

The ctrl+shift+p should allow you to enter vs code commands (if you are on windows; it is I believe option+shift+p on the Mac).

To complement the response, the actual shortcut for formatting the file you’re in is Ctrl + Shift + I

If you are on a Mac (apparently you are, using COMMAND-A), then the hotkey to call Command Palette is COMMAND-SHIFT-P). Alternatively Menu View / Command Palette...

Then you have to call actual Format Document command from there. The hotkey to call it directly is OPTION-SHIFT-F on my Mac.

I assume, you don’t need to install JuliaFormatter.jl on your own. In any case, I never did, and I have the working Format Document command on my Mac.

Thank you everyone.

On my MAC on VS Code editor. Option-Shift-F does format the julia code in the current selected text file. This solves my problem.

1 Like