User Tools

Site Tools


gibson:teaching:fall-2016:math753:notebook-workflow

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
gibson:teaching:fall-2016:math753:notebook-workflow [2016/09/01 10:03]
gibson [Executing Julia code in a notebook]
gibson:teaching:fall-2016:math753:notebook-workflow [2016/09/02 06:24] (current)
gibson [Summary of notebook keyboard shortcuts]
Line 5: Line 5:
   - Live Julia code   - Live Julia code
   - Graphical output   - Graphical output
- 
-====== Executing Julia code in a notebook ===== 
  
 Our first concern is working with the live Julia code cells. I'll illustrate on the "​Numbers,​ variables, and basic functions"​ notebook from the Hands-on Julia tutorial. You should start that notebook and follow along (see [[:​gibson:​teaching:​fall-2016:​math753:​julia-notebooks]]). ​ Our first concern is working with the live Julia code cells. I'll illustrate on the "​Numbers,​ variables, and basic functions"​ notebook from the Hands-on Julia tutorial. You should start that notebook and follow along (see [[:​gibson:​teaching:​fall-2016:​math753:​julia-notebooks]]). ​
  
 +-----
  
 ===== Executing a line of code with shift-enter ===== ===== Executing a line of code with shift-enter =====
Line 31: Line 29:
 {{ :​gibson:​teaching:​fall-2016:​math753:​julia-notebooks:​notebookworkflow3.jpg |}} {{ :​gibson:​teaching:​fall-2016:​math753:​julia-notebooks:​notebookworkflow3.jpg |}}
  
-===== +---- 
 + 
 +===== Execute and add new cell with alt-enter ===== 
 + 
 +When you want to execute a bunch of commands, it can get tedious to keep opening new cells. The "​alt-enter"​ shortcut executes the current cell then immediately starts a new cell below. I've used "​alt-enter"​ to compute a few powers of 10 as the notebook suggests. 
 + 
 +{{ :​gibson:​teaching:​fall-2016:​math753:​julia-notebooks:​notebookworkflow4.jpg |}} 
 + 
 +----- 
 + 
 +===== Summary of notebook keyboard shortcuts ===== 
 + 
 +All actions in the notebook can be performed with the mouse, but keyboard shortcuts are also available for the most common ones. The essential shortcuts to remember are the following:​ 
 + 
 +**Shift-Enter:​ run cell.** Execute the current cell, show output (if any), and jump to the next cell below. If Shift-Enter is invoked on the last cell, a new code cell will also be created. Note that in the notebook, typing Enter on its own never forces execution, but rather just inserts a new line in the current cell. Shift-Enter is equivalent to clicking the Cell | Run menu item.  
 + 
 +**Ctrl-Enter:​ run cell in-place.** ​ Execute the current cell as if it were in “terminal mode”, where any output is shown, but the cursor remains in the current cell. The cell’s entire contents are selected after execution, so you can just start typing and only the new input will be in the cell. This is convenient for doing quick experiments in place, or for querying things like filesystem content, without needing to create additional cells that you may not want to be saved in the notebook.  
 + 
 +**Alt-Enter:​ run cell, insert below.** Executes the current cell, shows the output, and inserts a new cell between the current cell and the cell below (if one exists). This is thus a shortcut for the sequence Shift-Enter,​ Ctrl-m a. (Ctrl-m a adds a new cell above the current one.)  
 + 
 +**Ctrl-m:** This is the prefix for all other shortcuts, which consist of Ctrl-m followed by a single letter or character. For example, if you type Ctrl-m h (that is, the sole letter h after Ctrl-m), IPython will show you all the available keyboard shortcuts. 
 + 
 +Here is the complete set of keyboard shortcuts available:​ 
 + 
 +^ Shortcut ^ Action ^ 
 +| Shift-Enter | run cell | 
 +| Ctrl-Enter | run cell in-place | 
 +| Alt-Enter | run cell, insert below | 
 +| Ctrl-m x | cut cell | 
 +| Ctrl-m c | copy cell | 
 +| Ctrl-m v | paste cell | 
 +| Ctrl-m d | delete cell | 
 +| Ctrl-m z | undo last cell deletion | 
 +| Ctrl-m - | split cell | 
 +| Ctrl-m a | insert cell above | 
 +| Ctrl-m b | insert cell below | 
 +| Ctrl-m o | toggle output | 
 +| Ctrl-m O | toggle output scroll | 
 +| Ctrl-m l | toggle line numbers | 
 +| Ctrl-m s | save notebook | 
 +| Ctrl-m j | move cell down | 
 +| Ctrl-m k | move cell up | 
 +| Ctrl-m y | code cell | 
 +| Ctrl-m m | markdown cell | 
 +| Ctrl-m t | raw cell | 
 +| Ctrl-m 1-6 | heading 1-6 cell | 
 +| Ctrl-m p | select previous | 
 +| Ctrl-m ​ | select next | 
 +| Ctrl-m ​ | interrupt kernel | 
 +| Ctrl-m . | restart kernel | 
 +| Ctrl-m h | show keyboard shortcuts | 
 + 
 +For more about controlling your Julia notebook, see the [[https://​ipython.org/​ipython-doc/​1/​interactive/​notebook.html | iPython notebook documentation]],​ from where this summary of shortcuts was copied.
gibson/teaching/fall-2016/math753/notebook-workflow.1472749382.txt.gz · Last modified: 2016/09/01 10:03 by gibson