You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Optionally install [Code Spell Checker](https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker) for spell checking
57
-
- See [documentation](https://github.com/James-Yu/LaTeX-Workshop#manual). The easiest use is to put the magic comment `!TEX program = pdflatex` at the top of a `.tex` file.
58
-
-
57
+
- See [documentation](https://github.com/James-Yu/LaTeX-Workshop#manual). The easiest use is to put the magic comment `!TEX program = pdflatex` at the top of a `.tex` file and then `F5`.
59
58
60
59
61
-
See the [VS Code documentation](https://code.visualstudio.com/docs/getstarted/userinterface) for an introduction.
60
+
See the [VS Code documentation](https://code.visualstudio.com/docs/getstarted/userinterface) for an introduction.
61
+
62
+
### Command Palette
62
63
63
64
A key feature is the [Command Palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette), which can be accessed with `<Ctrl+Shift+P>`.
With this, you can type partial strings for different commands and it helps you to find features of vscode and its extensions. This is so common that in these notes we
70
71
denote opening the command palette and searching for a command with things like `> Julia: Start REPL` , etc. You will only need to type part of the string, and the command palette remembers
71
-
your most commonly used
72
-
73
-
72
+
your most recent and common commands.
74
73
### Optional Extensions and Settings
75
74
76
-
77
-
Open the settings, either with `> Preferences: User Settings` (recall this can be found with the palette and `<Ctrl-Shift-P>`) or with the menu.
75
+
Open the settings with `> Preferences: User Settings` (see above for opening the command palette with `<Ctrl-Shift-P>`).
78
76
79
77
As a few optional suggestions for working with the settings,
80
78
@@ -83,10 +81,78 @@ As a few optional suggestions for working with the settings,
83
81
- Finally, if you are on Windows, search for `eol` and change `Files: Eol` to be `\n`.
84
82
85
83
84
+
(vscode)=
85
+
## Using VS Code with Julia
86
+
87
+
The documentation for the VS Code extension provides many examples:
88
+
-[Creating a Hello World](https://www.julia-vscode.org/docs/dev/gettingstarted/#Creating-Your-First-Julia-Hello-World-program-1)
In addition, there are excellent youtube videos about provide more background. FOr example, [Package Development in VSCode](https://www.youtube.com/watch?v=F1R3ETaRQXY) shows advanced features.
95
+
96
+
### Simple Example
97
+
To walk through a simple, but complete example.
98
+
99
+
Create a new directory on your computer, for example `hello_world` and then open VS Code in that folder This can be done several ways,
100
+
- Within a terminal on your operating system, navigate that directory and type `code .`
101
+
- On Windows, right click on the folder and choose `Open with Code` - trusting the authors as required on opening the folder.
102
+
- In the VS Code Menu, choose `File/Open Folder...`
103
+
104
+
Next, in the left hand panel, under `HELLO_WORLD`, right click and choose `New File` and create as `hello.jl`. The screen should look something like
Type some code as such `f(x) = x + 1` into the file, into the `.jl` file, save it, and while your mouse curser is on the line of code do `<Shift-Enter>`. If a julia REPL wasn't already started, it will be started and the code will be run within its kernel
At this point, the function is available for use within either the code or the REPL. You can get inline results by adding more code to the file and executing each line with `<Shift=Enter>`.
That code is also accessible within the REPL. Executing the function there,
123
+
124
+
```{figure} /_static/figures/vscode_repl_1.png
125
+
:width: 100%
126
+
```
86
127
128
+
Because the REPL and the files are synchronized, you can modify functions and simple choose `<shift-Enter>` to update their definitions before analyzing the results in the REPL or in the file itself.
129
+
130
+
131
+
### Adding Packages
132
+
133
+
Next we will go through simple use of the plotting and package management.
134
+
135
+
To add a package, we can execute a command in the REPL. First, type `]` to enter the package management mode, then `add Plots`. Depending on whether you have done similar operations before, this may download a lot of dependencies. See below for an example
Crucially, you will notice that two new files are created. `Project.toml` and `Manifest.toml`. These provide a snapshot of all of the packages used in this particular project.
142
+
143
+
Add code in the `.jl` file for a simple plot, and it will be shown on a separate pane
144
+
145
+
```{figure} /_static/figures/vscode_plots.png
146
+
:width: 100%
147
+
```
148
+
149
+
150
+
151
+
** Note:** The If you use the Julia REPL within VS Code, then it will automaticallly activate that project file. Otherwise, you will have to start your REPL with the `julia --project` from within that folder, or you will need to manually call `using Pkg; Pkg.activate()` after launching Julia.
87
152
88
153
(repl_main)=
89
154
## The REPL
155
+
Note that the REPL could also be started with `> Julia: Start REPL`, which should provide a prompt at the bottom of the window.
90
156
91
157
Previously, we discussed basic use of the Julia REPL ("Read-Evaluate-Print Loop").
92
158
@@ -158,93 +224,6 @@ using Test
158
224
159
225
will succeed.
160
226
161
-
## Atom
162
-
163
-
As discussed {doc}`previously <../getting_started_julia/getting_started>`, eventually you will want to use a fully fledged text editor.
164
-
165
-
The most feature-rich one for Julia development is [Atom](https://atom.io/), with the [Juno](http://junolab.org/) package.
166
-
167
-
There are several reasons to use a text editor like Atom, including
168
-
169
-
(upgrading_julia)=
170
-
#### Upgrading Julia
171
-
172
-
To get a new release working with Jupyter, run (in the new version's REPL)
173
-
174
-
```{code-block} julia
175
-
] add IJulia
176
-
] build IJulia
177
-
```
178
-
179
-
This will install (and build) the `IJulia` kernel.
180
-
181
-
To get it working with Atom, open the command palette and type "Julia Client: Settings."
182
-
183
-
Then, in the box labelled "Julia Path," enter the path to yor Julia executabe.
184
-
185
-
You can find the folder by running `Sys.BINDIR` in a new REPL, and then add the `/julia` at the end to give the exact path.
186
-
187
-
For example:
188
-
189
-
```{figure} /_static/figures/julia-path.png
190
-
:width: 100%
191
-
```
192
-
193
-
### Standard Layout
194
-
195
-
If you follow the instructions, you should see something like this when you open a new file.
196
-
197
-
If you don't, simply go to the command palette and type "Julia standard layout"
The bottom pane is a standard REPL, which supports the different modes above.
204
-
205
-
The "workspace" pane is a snapshot of currently-defined objects.
206
-
207
-
For example, if we define an object in the REPL
208
-
209
-
```{code-cell} julia
210
-
x = 2
211
-
```
212
-
213
-
Our workspace should read
214
-
215
-
```{figure} /_static/figures/juno-workspace-1.png
216
-
:width: 100%
217
-
```
218
-
219
-
The `ans` variable simply captures the result of the last computation.
220
-
221
-
The `Documentation` pane simply lets us query Julia documentation
222
-
223
-
```{figure} /_static/figures/juno-docs.png
224
-
:width: 100%
225
-
```
226
-
227
-
The `Plots` pane captures Julia plots output (the code is as follows)
228
-
229
-
```{code-block} julia
230
-
using Plots
231
-
gr(fmt = :png);
232
-
data = rand(10, 10)
233
-
h = heatmap(data)
234
-
```
235
-
236
-
```{figure} /_static/figures/juno-plots.png
237
-
:width: 100%
238
-
```
239
-
240
-
**Note:** The plots feature is not perfectly reliable across all plotting backends, see [the Basic Usage](http://docs.junolab.org/latest/man/basic_usage.html) page.
241
-
242
-
### Other Features
243
-
244
-
*`` Shift + Enter `` will evaluate a highlighted selection or line (as above).
245
-
* The run symbol in the left sidebar (or `Ctrl+Shift+Enter`) will run the whole file.
246
-
247
-
See [basic usage](http://docs.junolab.org/latest/man/basic_usage.html) for an exploration of features, and the [FAQ](http://docs.junolab.org/latest/man/faq.html) for more advanced steps.
248
227
249
228
(jl_packages)=
250
229
## Package Environments
@@ -335,12 +314,3 @@ without any arguments.
335
314
```{code-cell} julia
336
315
; rm -rf ExampleEnvironment
337
316
```
338
-
339
-
### InstantiateFromURL
340
-
341
-
With this knowledge, we can explain the operation of the setup block
342
-
343
-
344
-
What this `github_project` function does is activate (and if necessary, download, instantiate and precompile) a particular Julia environment.
0 commit comments