Skip to content

Commit

Permalink
Merge pull request #47 from nilsmartel/patch-1
Browse files Browse the repository at this point in the history
Include small details about formatting code
  • Loading branch information
pfitzseb authored Nov 7, 2021
2 parents 37a33e1 + 8a75ee8 commit e6b8ac0
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions docs/src/userguide/formatter.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# Formatting Code

Code formatting is powered by [JuliaFormatter.jl](https://github.com/domluna/JuliaFormatter.jl). Both the `Format Document` command (`Ctrl-Shift-I`) and `Format Selection` (`Ctrl-K Ctrl-F`) are supported.

The default formatting is fairly conservative and unintrusive, but you can customise it with a `.JuliaFormatter.toml`. Check out the [relevant documentation here](https://domluna.github.io/JuliaFormatter.jl/stable/).
The default formatting is fairly conservative and unintrusive, but you can customise it with a `.JuliaFormatter.toml`. Check out the [relevant documentation here](https://domluna.github.io/JuliaFormatter.jl/stable/).

Formatting helps to keep code readable by automatically aligning indentations and spaces.

The Julia formatter can automatically make this code:
```julia
f(x)=2x+3
print(f'( 2 ))

open("myfile.txt", "w") do io
write(io, "Hello world!")
end;
```

look like this:
```julia
f(x) = 2x + 3
print(f'(2))

open("myfile.txt", "w") do io
write(io, "Hello world!")
end;
```

It's the very same code, though now it's much easier to read.

In order to format your code press `shift + cmd|windows + p` to bring up the command palette and search for `Format Document`

```@raw html
<img width="741" alt="grafik" src="https://user-images.githubusercontent.com/28377948/135749171-c6708afb-0f08-4268-b041-d24de4226e7f.png">
```

0 comments on commit e6b8ac0

Please sign in to comment.