Show More
@@ -1,421 +1,445 b'' | |||||
1 | { |
|
1 | { | |
2 | "metadata": { |
|
2 | "metadata": { | |
3 | "name": "" |
|
3 | "name": "" | |
4 | }, |
|
4 | }, | |
5 | "nbformat": 3, |
|
5 | "nbformat": 3, | |
6 | "nbformat_minor": 0, |
|
6 | "nbformat_minor": 0, | |
7 | "worksheets": [ |
|
7 | "worksheets": [ | |
8 | { |
|
8 | { | |
9 | "cells": [ |
|
9 | "cells": [ | |
10 | { |
|
10 | { | |
11 | "cell_type": "heading", |
|
11 | "cell_type": "heading", | |
12 | "level": 1, |
|
12 | "level": 1, | |
13 | "metadata": {}, |
|
13 | "metadata": {}, | |
14 | "source": [ |
|
14 | "source": [ | |
15 | "User Interface" |
|
15 | "User Interface" | |
16 | ] |
|
16 | ] | |
17 | }, |
|
17 | }, | |
18 | { |
|
18 | { | |
19 | "cell_type": "markdown", |
|
19 | "cell_type": "markdown", | |
20 | "metadata": {}, |
|
20 | "metadata": {}, | |
21 | "source": [ |
|
21 | "source": [ | |
22 | "This notebook describes the user interface of the IPython Notebook. This includes both mouse and keyboard based navigation and interaction.\n", |
|
22 | "This notebook describes the user interface of the IPython Notebook. This includes both mouse and keyboard based navigation and interaction.\n", | |
23 | "\n", |
|
23 | "\n", | |
24 | "<div class=\"alert\" style=\"margin: 10px\">\n", |
|
24 | "<div class=\"alert\" style=\"margin: 10px\">\n", | |
25 | "As of IPython 2.0, the user interface has changed significantly. Because of this we highly recommend existing users to review this information after upgrading to IPython 2.0. All new users of IPython should review this information as well.\n", |
|
25 | "As of IPython 2.0, the user interface has changed significantly. Because of this we highly recommend existing users to review this information after upgrading to IPython 2.0. All new users of IPython should review this information as well.\n", | |
26 | "</div>" |
|
26 | "</div>" | |
27 | ] |
|
27 | ] | |
28 | }, |
|
28 | }, | |
29 | { |
|
29 | { | |
30 | "cell_type": "heading", |
|
30 | "cell_type": "heading", | |
31 | "level": 2, |
|
31 | "level": 2, | |
32 | "metadata": {}, |
|
32 | "metadata": {}, | |
33 | "source": [ |
|
33 | "source": [ | |
34 | "Modal editor" |
|
34 | "Modal editor" | |
35 | ] |
|
35 | ] | |
36 | }, |
|
36 | }, | |
37 | { |
|
37 | { | |
38 | "cell_type": "markdown", |
|
38 | "cell_type": "markdown", | |
39 | "metadata": {}, |
|
39 | "metadata": {}, | |
40 | "source": [ |
|
40 | "source": [ | |
41 | "Starting with IPython 2.0, the IPython Notebook has a modal user interface. This means that the keyboard does different things depending on which mode the Notebook is in. There are two modes: edit mode and command mode." |
|
41 | "Starting with IPython 2.0, the IPython Notebook has a modal user interface. This means that the keyboard does different things depending on which mode the Notebook is in. There are two modes: edit mode and command mode." | |
42 | ] |
|
42 | ] | |
43 | }, |
|
43 | }, | |
44 | { |
|
44 | { | |
45 | "cell_type": "heading", |
|
45 | "cell_type": "heading", | |
46 | "level": 3, |
|
46 | "level": 3, | |
47 | "metadata": {}, |
|
47 | "metadata": {}, | |
48 | "source": [ |
|
48 | "source": [ | |
49 | "Edit mode" |
|
49 | "Edit mode" | |
50 | ] |
|
50 | ] | |
51 | }, |
|
51 | }, | |
52 | { |
|
52 | { | |
53 | "cell_type": "markdown", |
|
53 | "cell_type": "markdown", | |
54 | "metadata": {}, |
|
54 | "metadata": {}, | |
55 | "source": [ |
|
55 | "source": [ | |
56 | "Edit mode is indicated by a green cell border and a prompt showing in the editor area:\n", |
|
56 | "Edit mode is indicated by a green cell border and a prompt showing in the editor area:\n", | |
57 | "\n", |
|
57 | "\n", | |
58 | "<img src=\"images/edit_mode.png\">\n", |
|
58 | "<img src=\"images/edit_mode.png\">\n", | |
59 | "\n", |
|
59 | "\n", | |
60 | "When a cell is in edit mode, you can type into the cell, like a normal text editor.\n", |
|
60 | "When a cell is in edit mode, you can type into the cell, like a normal text editor.\n", | |
61 | "\n", |
|
61 | "\n", | |
62 | "<div class=\"alert alert-success\" style=\"margin: 10px\">\n", |
|
62 | "<div class=\"alert alert-success\" style=\"margin: 10px\">\n", | |
63 | "Enter edit mode by pressing `enter` or using the mouse to click on a cell's editor area.\n", |
|
63 | "Enter edit mode by pressing `enter` or using the mouse to click on a cell's editor area.\n", | |
64 | "</div>" |
|
64 | "</div>" | |
65 | ] |
|
65 | ] | |
66 | }, |
|
66 | }, | |
67 | { |
|
67 | { | |
68 | "cell_type": "heading", |
|
68 | "cell_type": "heading", | |
69 | "level": 3, |
|
69 | "level": 3, | |
70 | "metadata": {}, |
|
70 | "metadata": {}, | |
71 | "source": [ |
|
71 | "source": [ | |
72 | "Command mode" |
|
72 | "Command mode" | |
73 | ] |
|
73 | ] | |
74 | }, |
|
74 | }, | |
75 | { |
|
75 | { | |
76 | "cell_type": "markdown", |
|
76 | "cell_type": "markdown", | |
77 | "metadata": {}, |
|
77 | "metadata": {}, | |
78 | "source": [ |
|
78 | "source": [ | |
79 | "Command mode is indicated by a grey cell border:\n", |
|
79 | "Command mode is indicated by a grey cell border:\n", | |
80 | "\n", |
|
80 | "\n", | |
81 | "<img src=\"images/command_mode.png\">\n", |
|
81 | "<img src=\"images/command_mode.png\">\n", | |
82 | "\n", |
|
82 | "\n", | |
83 | "When you are in command mode, you are able to edit the notebook as a whole, but not type into individual cells. Most importantly, in command mode, the keyboard is mapped to a set of shortcuts that let you perform notebook and cell actions efficiently. For example, if you are in command mode and you press `c`, you will copy the current cell - no modifier is needed.\n", |
|
83 | "When you are in command mode, you are able to edit the notebook as a whole, but not type into individual cells. Most importantly, in command mode, the keyboard is mapped to a set of shortcuts that let you perform notebook and cell actions efficiently. For example, if you are in command mode and you press `c`, you will copy the current cell - no modifier is needed.\n", | |
84 | "\n", |
|
84 | "\n", | |
85 | "<div class=\"alert alert-error\" style=\"margin: 10px\">\n", |
|
85 | "<div class=\"alert alert-error\" style=\"margin: 10px\">\n", | |
86 | "Don't try to type into a cell in command mode; unexpected things will happen!\n", |
|
86 | "Don't try to type into a cell in command mode; unexpected things will happen!\n", | |
87 | "</div>\n", |
|
87 | "</div>\n", | |
88 | "\n", |
|
88 | "\n", | |
89 | "<div class=\"alert alert-success\" style=\"margin: 10px\">\n", |
|
89 | "<div class=\"alert alert-success\" style=\"margin: 10px\">\n", | |
90 | "Enter command mode by pressing `esc` or using the mouse to click *outside* a cell's editor area.\n", |
|
90 | "Enter command mode by pressing `esc` or using the mouse to click *outside* a cell's editor area.\n", | |
91 | "</div>" |
|
91 | "</div>" | |
92 | ] |
|
92 | ] | |
93 | }, |
|
93 | }, | |
94 | { |
|
94 | { | |
95 | "cell_type": "heading", |
|
95 | "cell_type": "heading", | |
96 | "level": 2, |
|
96 | "level": 2, | |
97 | "metadata": {}, |
|
97 | "metadata": {}, | |
98 | "source": [ |
|
98 | "source": [ | |
99 | "Mouse navigation" |
|
99 | "Mouse navigation" | |
100 | ] |
|
100 | ] | |
101 | }, |
|
101 | }, | |
102 | { |
|
102 | { | |
103 | "cell_type": "markdown", |
|
103 | "cell_type": "markdown", | |
104 | "metadata": {}, |
|
104 | "metadata": {}, | |
105 | "source": [ |
|
105 | "source": [ | |
106 | "All navigation and actions in the Notebook are available using the mouse through the menubar and toolbar, which are both above the main Notebook area:\n", |
|
106 | "All navigation and actions in the Notebook are available using the mouse through the menubar and toolbar, which are both above the main Notebook area:\n", | |
107 | "\n", |
|
107 | "\n", | |
108 | "<img src=\"images/menubar_toolbar.png\">" |
|
108 | "<img src=\"images/menubar_toolbar.png\">" | |
109 | ] |
|
109 | ] | |
110 | }, |
|
110 | }, | |
111 | { |
|
111 | { | |
112 | "cell_type": "markdown", |
|
112 | "cell_type": "markdown", | |
113 | "metadata": {}, |
|
113 | "metadata": {}, | |
114 | "source": [ |
|
114 | "source": [ | |
115 | "The first idea of mouse based navigation is that **cells can be selected by clicking on them.** The currently selected cell gets a grey or green border depending on whether the notebook is in edit or command mode. If you click inside a cell's editor area, you will enter edit mode. If you click on the prompt or output area of a cell you will enter command mode.\n", |
|
115 | "The first idea of mouse based navigation is that **cells can be selected by clicking on them.** The currently selected cell gets a grey or green border depending on whether the notebook is in edit or command mode. If you click inside a cell's editor area, you will enter edit mode. If you click on the prompt or output area of a cell you will enter command mode.\n", | |
116 | "\n", |
|
116 | "\n", | |
117 | "If you are running this notebook in a live session (not on http://nbviewer.ipython.org) try selecting different cells and going between edit and command mode. Try typing into a cell." |
|
117 | "If you are running this notebook in a live session (not on http://nbviewer.ipython.org) try selecting different cells and going between edit and command mode. Try typing into a cell." | |
118 | ] |
|
118 | ] | |
119 | }, |
|
119 | }, | |
120 | { |
|
120 | { | |
121 | "cell_type": "markdown", |
|
121 | "cell_type": "markdown", | |
122 | "metadata": {}, |
|
122 | "metadata": {}, | |
123 | "source": [ |
|
123 | "source": [ | |
124 | "The second idea of mouse based navigation is that **cell actions usually apply to the currently selected cell**. Thus if you want to run the code in a cell, you would select it and click the \"Play\" button in the toolbar or the \"Cell:Run\" menu item. Similarly, to copy a cell you would select it and click the \"Copy\" button in the toolbar or the \"Edit:Copy\" menu item. With this simple pattern, you should be able to do most everything you need with the mouse.\n", |
|
124 | "The second idea of mouse based navigation is that **cell actions usually apply to the currently selected cell**. Thus if you want to run the code in a cell, you would select it and click the \"Play\" button in the toolbar or the \"Cell:Run\" menu item. Similarly, to copy a cell you would select it and click the \"Copy\" button in the toolbar or the \"Edit:Copy\" menu item. With this simple pattern, you should be able to do most everything you need with the mouse.\n", | |
125 | "\n", |
|
125 | "\n", | |
126 | "Markdown and heading cells have one other state that can be modified with the mouse. These cells can either be rendered or unrendered. When they are rendered, you will see a nice formatted representation of the cell's contents. When they are unrendered, you will see the raw text source of the cell. To render the selected cell with the mouse, click the \"Play\" button in the toolbar or the \"Cell:Run\" menu item. To unrender the selected cell, double click on the cell." |
|
126 | "Markdown and heading cells have one other state that can be modified with the mouse. These cells can either be rendered or unrendered. When they are rendered, you will see a nice formatted representation of the cell's contents. When they are unrendered, you will see the raw text source of the cell. To render the selected cell with the mouse, click the \"Play\" button in the toolbar or the \"Cell:Run\" menu item. To unrender the selected cell, double click on the cell." | |
127 | ] |
|
127 | ] | |
128 | }, |
|
128 | }, | |
129 | { |
|
129 | { | |
130 | "cell_type": "heading", |
|
130 | "cell_type": "heading", | |
131 | "level": 2, |
|
131 | "level": 2, | |
132 | "metadata": {}, |
|
132 | "metadata": {}, | |
133 | "source": [ |
|
133 | "source": [ | |
134 | "Keyboard Navigation" |
|
134 | "Keyboard Navigation" | |
135 | ] |
|
135 | ] | |
136 | }, |
|
136 | }, | |
137 | { |
|
137 | { | |
138 | "cell_type": "markdown", |
|
138 | "cell_type": "markdown", | |
139 | "metadata": {}, |
|
139 | "metadata": {}, | |
140 | "source": [ |
|
140 | "source": [ | |
141 | "The modal user interface of the IPython Notebook has been optimized for efficient keyboard usage. This is made possible by having two different sets of keyboard shortcuts: one set that is active in edit mode and another in command mode.\n", |
|
141 | "The modal user interface of the IPython Notebook has been optimized for efficient keyboard usage. This is made possible by having two different sets of keyboard shortcuts: one set that is active in edit mode and another in command mode.\n", | |
142 | "\n", |
|
142 | "\n", | |
143 | "The most important keyboard shortcuts are `enter`, which enters edit mode, and `esc`, which enters command mode.\n", |
|
143 | "The most important keyboard shortcuts are `enter`, which enters edit mode, and `esc`, which enters command mode.\n", | |
144 | "\n", |
|
144 | "\n", | |
145 | "In edit mode, most of the keyboard is dedicated to typing into the cell's editor. Thus, in edit mode there are relatively few shortcuts:" |
|
145 | "In edit mode, most of the keyboard is dedicated to typing into the cell's editor. Thus, in edit mode there are relatively few shortcuts:" | |
146 | ] |
|
146 | ] | |
147 | }, |
|
147 | }, | |
148 | { |
|
148 | { | |
149 | "cell_type": "markdown", |
|
149 | "cell_type": "markdown", | |
150 | "metadata": {}, |
|
150 | "metadata": {}, | |
151 | "source": [ |
|
151 | "source": [ | |
152 | "The `display_edit_shortcuts()` function used here is defined in the [Utilities section](#Utilities) at the bottom of this notebook." |
|
152 | "The `display_edit_shortcuts()` function used here is defined in the [Utilities section](#Utilities) at the bottom of this notebook." | |
153 | ] |
|
153 | ] | |
154 | }, |
|
154 | }, | |
155 | { |
|
155 | { | |
156 | "cell_type": "code", |
|
156 | "cell_type": "code", | |
157 | "collapsed": false, |
|
157 | "collapsed": false, | |
158 | "input": [ |
|
158 | "input": [ | |
159 | "display_edit_shortcuts()" |
|
159 | "display_edit_shortcuts()" | |
160 | ], |
|
160 | ], | |
161 | "language": "python", |
|
161 | "language": "python", | |
162 | "metadata": {}, |
|
162 | "metadata": {}, | |
163 | "outputs": [ |
|
163 | "outputs": [ | |
164 | { |
|
164 | { | |
165 | "html": [ |
|
165 | "html": [ | |
166 |
"<div class=\"hbox\"><div class=\"box-flex0\"><div class=\"quickhelp\"><span class=\"shortcut_key\">esc</span><span class=\"shortcut_descr\"> : command mode</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">ctrl+m</span><span class=\"shortcut_descr\"> : command mode</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">shift+enter</span><span class=\"shortcut_descr\"> : run cell</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">ctrl+enter</span><span class=\"shortcut_descr\"> : run cell, select below</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">alt+enter</span><span class=\"shortcut_descr\"> : run cell, insert below |
|
166 | "<div class=\"hbox\"><div class=\"box-flex0\"><div class=\"quickhelp\"><span class=\"shortcut_key\">esc</span><span class=\"shortcut_descr\"> : command mode</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">ctrl+m</span><span class=\"shortcut_descr\"> : command mode</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">shift+enter</span><span class=\"shortcut_descr\"> : run cell</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">ctrl+enter</span><span class=\"shortcut_descr\"> : run cell, select below</span></div></div><div class=\"box-flex0\"><div class=\"quickhelp\"><span class=\"shortcut_key\">alt+enter</span><span class=\"shortcut_descr\"> : run cell, insert below</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">alt+-</span><span class=\"shortcut_descr\"> : split cell</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">meta+s</span><span class=\"shortcut_descr\"> : save notebook</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">ctrl+s</span><span class=\"shortcut_descr\"> : save notebook</span></div></div></div>" | |
167 | ], |
|
167 | ], | |
168 | "output_type": "display_data" |
|
168 | "output_type": "display_data" | |
169 | }, |
|
169 | }, | |
170 | { |
|
170 | { | |
171 | "javascript": [ |
|
171 | "javascript": [ | |
172 | "var help = IPython.quick_help.build_edit_help();\n", |
|
172 | "var help = IPython.quick_help.build_edit_help();\n", | |
173 | "help.children().first().remove();\n", |
|
173 | "help.children().first().remove();\n", | |
174 | "this.append_output({output_type: 'display_data', html: help.html()});" |
|
174 | "this.append_output({output_type: 'display_data', html: help.html()});" | |
175 | ], |
|
175 | ], | |
176 | "metadata": {}, |
|
176 | "metadata": {}, | |
177 | "output_type": "display_data", |
|
177 | "output_type": "display_data", | |
178 | "text": [ |
|
178 | "text": [ | |
179 |
"<IPython.core.display.Javascript at 0x10e |
|
179 | "<IPython.core.display.Javascript at 0x10e8d1a50>" | |
180 | ] |
|
180 | ] | |
181 | } |
|
181 | } | |
182 | ], |
|
182 | ], | |
183 |
"prompt_number": 1 |
|
183 | "prompt_number": 17 | |
184 | }, |
|
184 | }, | |
185 | { |
|
185 | { | |
186 | "cell_type": "markdown", |
|
186 | "cell_type": "markdown", | |
187 | "metadata": {}, |
|
187 | "metadata": {}, | |
188 | "source": [ |
|
188 | "source": [ | |
189 | "There are two other keyboard shortcuts in edit mode that are not listed here:\n", |
|
189 | "There are two other keyboard shortcuts in edit mode that are not listed here:\n", | |
190 | "\n", |
|
190 | "\n", | |
191 | "* `tab`: trigger \"tab\" completion\n", |
|
191 | "* `tab`: trigger \"tab\" completion\n", | |
192 | "* `shift+tab`: open the tooltip" |
|
192 | "* `shift+tab`: open the tooltip" | |
193 | ] |
|
193 | ] | |
194 | }, |
|
194 | }, | |
195 | { |
|
195 | { | |
196 | "cell_type": "markdown", |
|
196 | "cell_type": "markdown", | |
197 | "metadata": {}, |
|
197 | "metadata": {}, | |
198 | "source": [ |
|
198 | "source": [ | |
199 | "In command mode, the entire keyboard is available for shortcuts:" |
|
199 | "In command mode, the entire keyboard is available for shortcuts:" | |
200 | ] |
|
200 | ] | |
201 | }, |
|
201 | }, | |
202 | { |
|
202 | { | |
203 | "cell_type": "code", |
|
203 | "cell_type": "code", | |
204 | "collapsed": false, |
|
204 | "collapsed": false, | |
205 | "input": [ |
|
205 | "input": [ | |
206 | "display_command_shortcuts()" |
|
206 | "display_command_shortcuts()" | |
207 | ], |
|
207 | ], | |
208 | "language": "python", |
|
208 | "language": "python", | |
209 | "metadata": {}, |
|
209 | "metadata": {}, | |
210 | "outputs": [ |
|
210 | "outputs": [ | |
211 | { |
|
211 | { | |
212 | "html": [ |
|
212 | "html": [ | |
213 | "<div class=\"hbox\"><div class=\"box-flex0\"><div class=\"quickhelp\"><span class=\"shortcut_key\">enter</span><span class=\"shortcut_descr\"> : edit mode</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">shift+enter</span><span class=\"shortcut_descr\"> : run cell</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">ctrl+enter</span><span class=\"shortcut_descr\"> : run cell, select below</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">alt+enter</span><span class=\"shortcut_descr\"> : run cell, insert below</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">y</span><span class=\"shortcut_descr\"> : to code</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">m</span><span class=\"shortcut_descr\"> : to markdown</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">t</span><span class=\"shortcut_descr\"> : to raw</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">1</span><span class=\"shortcut_descr\"> : to heading 1</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">2</span><span class=\"shortcut_descr\"> : to heading 2</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">3</span><span class=\"shortcut_descr\"> : to heading 3</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">4</span><span class=\"shortcut_descr\"> : to heading 4</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">5</span><span class=\"shortcut_descr\"> : to heading 5</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">6</span><span class=\"shortcut_descr\"> : to heading 6</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">up</span><span class=\"shortcut_descr\"> : select previous cell</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">down</span><span class=\"shortcut_descr\"> : select next cell</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">k</span><span class=\"shortcut_descr\"> : select previous cell</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">j</span><span class=\"shortcut_descr\"> : select next cell</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">ctrl+k</span><span class=\"shortcut_descr\"> : move cell up</span></div></div><div class=\"box-flex0\"><div class=\"quickhelp\"><span class=\"shortcut_key\">ctrl+j</span><span class=\"shortcut_descr\"> : move cell down</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">a</span><span class=\"shortcut_descr\"> : insert cell above</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">b</span><span class=\"shortcut_descr\"> : insert cell below</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">x</span><span class=\"shortcut_descr\"> : cut cell</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">c</span><span class=\"shortcut_descr\"> : copy cell</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">v</span><span class=\"shortcut_descr\"> : paste cell below</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">z</span><span class=\"shortcut_descr\"> : undo last delete</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">d</span><span class=\"shortcut_descr\"> : delete cell (press twice)</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">shift+=</span><span class=\"shortcut_descr\"> : merge cell below</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">s</span><span class=\"shortcut_descr\"> : save notebook</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">meta+s</span><span class=\"shortcut_descr\"> : save notebook</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">ctrl+s</span><span class=\"shortcut_descr\"> : save notebook</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">l</span><span class=\"shortcut_descr\"> : toggle line numbers</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">o</span><span class=\"shortcut_descr\"> : toggle output</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">shift+o</span><span class=\"shortcut_descr\"> : toggle output</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">h</span><span class=\"shortcut_descr\"> : keyboard shortcuts</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">i</span><span class=\"shortcut_descr\"> : interrupt kernel</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">.</span><span class=\"shortcut_descr\"> : restart kernel</span></div></div></div>" |
|
213 | "<div class=\"hbox\"><div class=\"box-flex0\"><div class=\"quickhelp\"><span class=\"shortcut_key\">enter</span><span class=\"shortcut_descr\"> : edit mode</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">shift+enter</span><span class=\"shortcut_descr\"> : run cell</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">ctrl+enter</span><span class=\"shortcut_descr\"> : run cell, select below</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">alt+enter</span><span class=\"shortcut_descr\"> : run cell, insert below</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">y</span><span class=\"shortcut_descr\"> : to code</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">m</span><span class=\"shortcut_descr\"> : to markdown</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">t</span><span class=\"shortcut_descr\"> : to raw</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">1</span><span class=\"shortcut_descr\"> : to heading 1</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">2</span><span class=\"shortcut_descr\"> : to heading 2</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">3</span><span class=\"shortcut_descr\"> : to heading 3</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">4</span><span class=\"shortcut_descr\"> : to heading 4</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">5</span><span class=\"shortcut_descr\"> : to heading 5</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">6</span><span class=\"shortcut_descr\"> : to heading 6</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">up</span><span class=\"shortcut_descr\"> : select previous cell</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">down</span><span class=\"shortcut_descr\"> : select next cell</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">k</span><span class=\"shortcut_descr\"> : select previous cell</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">j</span><span class=\"shortcut_descr\"> : select next cell</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">ctrl+k</span><span class=\"shortcut_descr\"> : move cell up</span></div></div><div class=\"box-flex0\"><div class=\"quickhelp\"><span class=\"shortcut_key\">ctrl+j</span><span class=\"shortcut_descr\"> : move cell down</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">a</span><span class=\"shortcut_descr\"> : insert cell above</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">b</span><span class=\"shortcut_descr\"> : insert cell below</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">x</span><span class=\"shortcut_descr\"> : cut cell</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">c</span><span class=\"shortcut_descr\"> : copy cell</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">v</span><span class=\"shortcut_descr\"> : paste cell below</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">z</span><span class=\"shortcut_descr\"> : undo last delete</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">d</span><span class=\"shortcut_descr\"> : delete cell (press twice)</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">shift+=</span><span class=\"shortcut_descr\"> : merge cell below</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">s</span><span class=\"shortcut_descr\"> : save notebook</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">meta+s</span><span class=\"shortcut_descr\"> : save notebook</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">ctrl+s</span><span class=\"shortcut_descr\"> : save notebook</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">l</span><span class=\"shortcut_descr\"> : toggle line numbers</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">o</span><span class=\"shortcut_descr\"> : toggle output</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">shift+o</span><span class=\"shortcut_descr\"> : toggle output</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">h</span><span class=\"shortcut_descr\"> : keyboard shortcuts</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">i</span><span class=\"shortcut_descr\"> : interrupt kernel</span></div><div class=\"quickhelp\"><span class=\"shortcut_key\">.</span><span class=\"shortcut_descr\"> : restart kernel</span></div></div></div>" | |
214 | ], |
|
214 | ], | |
215 | "output_type": "display_data" |
|
215 | "output_type": "display_data" | |
216 | }, |
|
216 | }, | |
217 | { |
|
217 | { | |
218 | "javascript": [ |
|
218 | "javascript": [ | |
219 | "var help = IPython.quick_help.build_command_help();\n", |
|
219 | "var help = IPython.quick_help.build_command_help();\n", | |
220 | "help.children().first().remove();\n", |
|
220 | "help.children().first().remove();\n", | |
221 | "this.append_output({output_type: 'display_data', html: help.html()});" |
|
221 | "this.append_output({output_type: 'display_data', html: help.html()});" | |
222 | ], |
|
222 | ], | |
223 | "metadata": {}, |
|
223 | "metadata": {}, | |
224 | "output_type": "display_data", |
|
224 | "output_type": "display_data", | |
225 | "text": [ |
|
225 | "text": [ | |
226 |
"<IPython.core.display.Javascript at 0x10e |
|
226 | "<IPython.core.display.Javascript at 0x10e8d1650>" | |
227 | ] |
|
227 | ] | |
228 | } |
|
228 | } | |
229 | ], |
|
229 | ], | |
230 |
"prompt_number": 1 |
|
230 | "prompt_number": 18 | |
231 | }, |
|
231 | }, | |
232 | { |
|
232 | { | |
233 | "cell_type": "markdown", |
|
233 | "cell_type": "markdown", | |
234 | "metadata": {}, |
|
234 | "metadata": {}, | |
235 | "source": [ |
|
235 | "source": [ | |
236 | "Here the rough order in which we recommend learning the command mode shortcuts:\n", |
|
236 | "Here the rough order in which we recommend learning the command mode shortcuts:\n", | |
237 | "\n", |
|
237 | "\n", | |
238 | "1. Basic navigation: `enter`, `shift-enter`, `up/k`, `down/j`\n", |
|
238 | "1. Basic navigation: `enter`, `shift-enter`, `up/k`, `down/j`\n", | |
239 | "2. Saving the notebook: `s`\n", |
|
239 | "2. Saving the notebook: `s`\n", | |
240 | "2. Cell types: `y`, `m`, `1-6`, `t`\n", |
|
240 | "2. Cell types: `y`, `m`, `1-6`, `t`\n", | |
241 | "3. Cell creation and movement: `a`, `b`, `ctrl+k`, `ctrl+j`\n", |
|
241 | "3. Cell creation and movement: `a`, `b`, `ctrl+k`, `ctrl+j`\n", | |
242 | "4. Cell editing: `x`, `c`, `v`, `d`, `z`, `shift+=`\n", |
|
242 | "4. Cell editing: `x`, `c`, `v`, `d`, `z`, `shift+=`\n", | |
243 | "5. Kernel operations: `i`, `.`" |
|
243 | "5. Kernel operations: `i`, `.`" | |
244 | ] |
|
244 | ] | |
245 | }, |
|
245 | }, | |
246 | { |
|
246 | { | |
247 | "cell_type": "heading", |
|
247 | "cell_type": "heading", | |
248 | "level": 2, |
|
248 | "level": 2, | |
249 | "metadata": {}, |
|
249 | "metadata": {}, | |
250 | "source": [ |
|
250 | "source": [ | |
251 | "Keyboard shortcut customization" |
|
251 | "Keyboard shortcut customization" | |
252 | ] |
|
252 | ] | |
253 | }, |
|
253 | }, | |
254 | { |
|
254 | { | |
255 | "cell_type": "markdown", |
|
255 | "cell_type": "markdown", | |
256 | "metadata": {}, |
|
256 | "metadata": {}, | |
257 | "source": [ |
|
257 | "source": [ | |
258 | "Starting with IPython 2.0 keyboard shortcuts in command and edit mode are fully customizable. These customizations are made using the IPython JavaScript API. Here is an example that makes the `r` key available for running a cell:" |
|
258 | "Starting with IPython 2.0 keyboard shortcuts in command and edit mode are fully customizable. These customizations are made using the IPython JavaScript API. Here is an example that makes the `r` key available for running a cell:" | |
259 | ] |
|
259 | ] | |
260 | }, |
|
260 | }, | |
261 | { |
|
261 | { | |
262 | "cell_type": "code", |
|
262 | "cell_type": "code", | |
263 | "collapsed": false, |
|
263 | "collapsed": false, | |
264 | "input": [ |
|
264 | "input": [ | |
265 | "%%javascript\n", |
|
265 | "%%javascript\n", | |
266 | "\n", |
|
266 | "\n", | |
267 | "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', {\n", |
|
267 | "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', {\n", | |
268 | " help : 'run cell',\n", |
|
268 | " help : 'run cell',\n", | |
269 | " help_index : 'zz',\n", |
|
269 | " help_index : 'zz',\n", | |
270 | " handler : function (event) {\n", |
|
270 | " handler : function (event) {\n", | |
271 | " IPython.notebook.execute_cell();\n", |
|
271 | " IPython.notebook.execute_cell();\n", | |
272 | " return false;\n", |
|
272 | " return false;\n", | |
273 | " }}\n", |
|
273 | " }}\n", | |
274 | ");" |
|
274 | ");" | |
275 | ], |
|
275 | ], | |
276 | "language": "python", |
|
276 | "language": "python", | |
277 | "metadata": {}, |
|
277 | "metadata": {}, | |
278 | "outputs": [ |
|
278 | "outputs": [ | |
279 | { |
|
279 | { | |
280 | "javascript": [ |
|
280 | "javascript": [ | |
281 | "\n", |
|
281 | "\n", | |
282 | "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', {\n", |
|
282 | "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', {\n", | |
283 | " help : 'run cell',\n", |
|
283 | " help : 'run cell',\n", | |
284 |
" help_index : ' |
|
284 | " help_index : 'zz',\n", | |
285 | " handler : function (event) {\n", |
|
285 | " handler : function (event) {\n", | |
286 | " IPython.notebook.execute_cell();\n", |
|
286 | " IPython.notebook.execute_cell();\n", | |
287 | " return false;\n", |
|
287 | " return false;\n", | |
288 | " }}\n", |
|
288 | " }}\n", | |
289 | ");" |
|
289 | ");" | |
290 | ], |
|
290 | ], | |
291 | "metadata": {}, |
|
291 | "metadata": {}, | |
292 | "output_type": "display_data", |
|
292 | "output_type": "display_data", | |
293 | "text": [ |
|
293 | "text": [ | |
294 |
"<IPython.core.display.Javascript at 0x10 |
|
294 | "<IPython.core.display.Javascript at 0x10e8d1890>" | |
295 | ] |
|
295 | ] | |
296 | } |
|
296 | } | |
297 | ], |
|
297 | ], | |
298 |
"prompt_number": |
|
298 | "prompt_number": 7 | |
299 | }, |
|
299 | }, | |
300 | { |
|
300 | { | |
301 | "cell_type": "markdown", |
|
301 | "cell_type": "markdown", | |
302 | "metadata": {}, |
|
302 | "metadata": {}, | |
303 | "source": [ |
|
303 | "source": [ | |
304 | "There are a couple of points to mention about this API:\n", |
|
304 | "There are a couple of points to mention about this API:\n", | |
305 | "\n", |
|
305 | "\n", | |
306 | "* The `help_index` field is used to sort the shortcuts in the Keyboard Shortcuts help dialog. It defaults to `zz`.\n", |
|
306 | "* The `help_index` field is used to sort the shortcuts in the Keyboard Shortcuts help dialog. It defaults to `zz`.\n", | |
307 | "* When a handler returns `false` it indicates that the event should stop propagating and the default action should not be performed. For further details about the `event` object or event handling, see the jQuery docs.\n", |
|
307 | "* When a handler returns `false` it indicates that the event should stop propagating and the default action should not be performed. For further details about the `event` object or event handling, see the jQuery docs.\n", | |
308 | "* If you don't need a `help` or `help_index` field, you can simply pass a function as the second argument to `add_shortcut`." |
|
308 | "* If you don't need a `help` or `help_index` field, you can simply pass a function as the second argument to `add_shortcut`." | |
309 | ] |
|
309 | ] | |
310 | }, |
|
310 | }, | |
311 | { |
|
311 | { | |
312 | "cell_type": "code", |
|
312 | "cell_type": "code", | |
313 | "collapsed": false, |
|
313 | "collapsed": false, | |
314 | "input": [ |
|
314 | "input": [ | |
315 | "%%javascript\n", |
|
315 | "%%javascript\n", | |
316 | "\n", |
|
316 | "\n", | |
317 | "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', function (event) {\n", |
|
317 | "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', function (event) {\n", | |
318 | " IPython.notebook.execute_cell();\n", |
|
318 | " IPython.notebook.execute_cell();\n", | |
319 | " return false;\n", |
|
319 | " return false;\n", | |
320 | "});" |
|
320 | "});" | |
321 | ], |
|
321 | ], | |
322 | "language": "python", |
|
322 | "language": "python", | |
323 | "metadata": {}, |
|
323 | "metadata": {}, | |
324 | "outputs": [ |
|
324 | "outputs": [ | |
325 | { |
|
325 | { | |
326 | "javascript": [ |
|
326 | "javascript": [ | |
327 | "\n", |
|
327 | "\n", | |
328 | "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', function (event) {\n", |
|
328 | "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', function (event) {\n", | |
329 | " IPython.notebook.execute_cell();\n", |
|
329 | " IPython.notebook.execute_cell();\n", | |
330 | " return false;\n", |
|
330 | " return false;\n", | |
331 | "});" |
|
331 | "});" | |
332 | ], |
|
332 | ], | |
333 | "metadata": {}, |
|
333 | "metadata": {}, | |
334 | "output_type": "display_data", |
|
334 | "output_type": "display_data", | |
335 | "text": [ |
|
335 | "text": [ | |
336 | "<IPython.core.display.Javascript at 0x1019baf90>" |
|
336 | "<IPython.core.display.Javascript at 0x1019baf90>" | |
337 | ] |
|
337 | ] | |
338 | } |
|
338 | } | |
339 | ], |
|
339 | ], | |
340 | "prompt_number": 11 |
|
340 | "prompt_number": 11 | |
341 | }, |
|
341 | }, | |
342 | { |
|
342 | { | |
343 | "cell_type": "markdown", |
|
343 | "cell_type": "markdown", | |
344 | "metadata": {}, |
|
344 | "metadata": {}, | |
345 | "source": [ |
|
345 | "source": [ | |
346 | "Likewise, to remove a shortcut, use `remove_shortcut`:" |
|
346 | "Likewise, to remove a shortcut, use `remove_shortcut`:" | |
347 | ] |
|
347 | ] | |
348 | }, |
|
348 | }, | |
349 | { |
|
349 | { | |
350 | "cell_type": "code", |
|
350 | "cell_type": "code", | |
351 | "collapsed": false, |
|
351 | "collapsed": false, | |
352 | "input": [ |
|
352 | "input": [ | |
353 | "%%javascript\n", |
|
353 | "%%javascript\n", | |
354 | "\n", |
|
354 | "\n", | |
355 | "IPython.keyboard_manager.command_shortcuts.remove_shortcut('r');" |
|
355 | "IPython.keyboard_manager.command_shortcuts.remove_shortcut('r');" | |
356 | ], |
|
356 | ], | |
357 | "language": "python", |
|
357 | "language": "python", | |
358 | "metadata": {}, |
|
358 | "metadata": {}, | |
359 | "outputs": [ |
|
359 | "outputs": [ | |
360 | { |
|
360 | { | |
361 | "javascript": [ |
|
361 | "javascript": [ | |
362 | "\n", |
|
362 | "\n", | |
363 | "IPython.keyboard_manager.command_shortcuts.remove_shortcut('r');" |
|
363 | "IPython.keyboard_manager.command_shortcuts.remove_shortcut('r');" | |
364 | ], |
|
364 | ], | |
365 | "metadata": {}, |
|
365 | "metadata": {}, | |
366 | "output_type": "display_data", |
|
366 | "output_type": "display_data", | |
367 | "text": [ |
|
367 | "text": [ | |
368 |
"<IPython.core.display.Javascript at 0x101 |
|
368 | "<IPython.core.display.Javascript at 0x10e8d1950>" | |
369 | ] |
|
369 | ] | |
370 | } |
|
370 | } | |
371 | ], |
|
371 | ], | |
372 | "prompt_number": 8 |
|
372 | "prompt_number": 8 | |
373 | }, |
|
373 | }, | |
374 | { |
|
374 | { | |
375 | "cell_type": "markdown", |
|
375 | "cell_type": "markdown", | |
376 | "metadata": {}, |
|
376 | "metadata": {}, | |
377 | "source": [ |
|
377 | "source": [ | |
378 | "If you want your keyboard shortcuts to be active for all of your notebooks, put the above API calls into your `custom.js` file." |
|
378 | "If you want your keyboard shortcuts to be active for all of your notebooks, put the above API calls into your `custom.js` file." | |
379 | ] |
|
379 | ] | |
380 | }, |
|
380 | }, | |
381 | { |
|
381 | { | |
382 | "cell_type": "heading", |
|
382 | "cell_type": "heading", | |
383 | "level": 2, |
|
383 | "level": 2, | |
384 | "metadata": {}, |
|
384 | "metadata": {}, | |
385 | "source": [ |
|
385 | "source": [ | |
386 | "Utilities" |
|
386 | "Utilities" | |
387 | ] |
|
387 | ] | |
388 | }, |
|
388 | }, | |
389 | { |
|
389 | { | |
390 | "cell_type": "markdown", |
|
390 | "cell_type": "markdown", | |
391 | "metadata": {}, |
|
391 | "metadata": {}, | |
392 | "source": [ |
|
392 | "source": [ | |
393 | "We use the following functions to generate the keyboard shortcut listings above." |
|
393 | "We use the following functions to generate the keyboard shortcut listings above." | |
394 | ] |
|
394 | ] | |
395 | }, |
|
395 | }, | |
396 | { |
|
396 | { | |
397 | "cell_type": "code", |
|
397 | "cell_type": "code", | |
398 | "collapsed": false, |
|
398 | "collapsed": false, | |
399 | "input": [ |
|
399 | "input": [ | |
400 | "from IPython.display import Javascript, display\n", |
|
400 | "from IPython.display import Javascript, display, HTML\n", | |
401 | "\n", |
|
401 | "\n", | |
402 | "t = \"\"\"var help = IPython.quick_help.build_{0}_help();\n", |
|
402 | "t = \"\"\"var help = IPython.quick_help.build_{0}_help();\n", | |
403 | "help.children().first().remove();\n", |
|
403 | "help.children().first().remove();\n", | |
404 | "this.append_output({{output_type: 'display_data', html: help.html()}});\"\"\"\n", |
|
404 | "this.append_output({{output_type: 'display_data', html: help.html()}});\"\"\"\n", | |
405 | "\n", |
|
405 | "\n", | |
406 | "def display_command_shortcuts():\n", |
|
406 | "def display_command_shortcuts():\n", | |
407 | " display(Javascript(t.format('command')))\n", |
|
407 | " display(Javascript(t.format('command')))\n", | |
408 | "\n", |
|
408 | "\n", | |
409 | "def display_edit_shortcuts():\n", |
|
409 | "def display_edit_shortcuts():\n", | |
410 |
" display(Javascript(t.format('edit'))) |
|
410 | " display(Javascript(t.format('edit')))\n", | |
|
411 | "\n", | |||
|
412 | "display(HTML(\"\"\"\n", | |||
|
413 | "<style>\n", | |||
|
414 | ".shortcut_key {display: inline-block; width: 15ex; text-align: right; font-family: monospace;}\n", | |||
|
415 | ".shortcut_descr {display: inline-block;}\n", | |||
|
416 | "div.quickhelp {float: none; width: 100%;}\n", | |||
|
417 | "</style>\n", | |||
|
418 | "\"\"\"))" | |||
411 | ], |
|
419 | ], | |
412 | "language": "python", |
|
420 | "language": "python", | |
413 | "metadata": {}, |
|
421 | "metadata": {}, | |
414 |
"outputs": [ |
|
422 | "outputs": [ | |
415 | "prompt_number": 2 |
|
423 | { | |
|
424 | "html": [ | |||
|
425 | "\n", | |||
|
426 | "<style>\n", | |||
|
427 | ".shortcut_key {display: inline-block; width: 15ex; text-align: right; font-family: monospace;}\n", | |||
|
428 | ".shortcut_descr {display: inline-block;}\n", | |||
|
429 | "div.quickhelp {float: none; width: 100%;}\n", | |||
|
430 | "</style>\n" | |||
|
431 | ], | |||
|
432 | "metadata": {}, | |||
|
433 | "output_type": "display_data", | |||
|
434 | "text": [ | |||
|
435 | "<IPython.core.display.HTML at 0x10e8b0710>" | |||
|
436 | ] | |||
|
437 | } | |||
|
438 | ], | |||
|
439 | "prompt_number": 16 | |||
416 | } |
|
440 | } | |
417 | ], |
|
441 | ], | |
418 | "metadata": {} |
|
442 | "metadata": {} | |
419 | } |
|
443 | } | |
420 | ] |
|
444 | ] | |
421 | } No newline at end of file |
|
445 | } |
General Comments 0
You need to be logged in to leave comments.
Login now