-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #47 from nilsmartel/patch-1
Include small details about formatting code
- Loading branch information
Showing
1 changed file
with
31 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"> | ||
``` |