##// END OF EJS Templates
Pulling in content and rewriting from ipython-in-depth.
Brian E. Granger -
Show More
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -1,9 +1,149 b''
1 {
1 {
2 "metadata": {
2 "metadata": {
3 "name": "",
3 "name": ""
4 "signature": "sha256:0abf067a20ebda26a671db997ac954770350d292dff7b7d6a4ace8808f70aca1"
5 },
4 },
6 "nbformat": 3,
5 "nbformat": 3,
7 "nbformat_minor": 0,
6 "nbformat_minor": 0,
8 "worksheets": []
7 "worksheets": [
8 {
9 "cells": [
10 {
11 "cell_type": "heading",
12 "level": 1,
13 "metadata": {},
14 "source": [
15 "Keyboard Shortcut Customization"
16 ]
17 },
18 {
19 "cell_type": "markdown",
20 "metadata": {},
21 "source": [
22 "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:"
23 ]
24 },
25 {
26 "cell_type": "code",
27 "collapsed": false,
28 "input": [
29 "%%javascript\n",
30 "\n",
31 "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', {\n",
32 " help : 'run cell',\n",
33 " help_index : 'zz',\n",
34 " handler : function (event) {\n",
35 " IPython.notebook.execute_cell();\n",
36 " return false;\n",
37 " }}\n",
38 ");"
39 ],
40 "language": "python",
41 "metadata": {},
42 "outputs": [
43 {
44 "javascript": [
45 "\n",
46 "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', {\n",
47 " help : 'run cell',\n",
48 " help_index : 'zz',\n",
49 " handler : function (event) {\n",
50 " IPython.notebook.execute_cell();\n",
51 " return false;\n",
52 " }}\n",
53 ");"
54 ],
55 "metadata": {},
56 "output_type": "display_data",
57 "text": [
58 "<IPython.core.display.Javascript at 0x10e8d1890>"
59 ]
60 }
61 ],
62 "prompt_number": 7
63 },
64 {
65 "cell_type": "markdown",
66 "metadata": {},
67 "source": [
68 "There are a couple of points to mention about this API:\n",
69 "\n",
70 "* The `help_index` field is used to sort the shortcuts in the Keyboard Shortcuts help dialog. It defaults to `zz`.\n",
71 "* 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",
72 "* If you don't need a `help` or `help_index` field, you can simply pass a function as the second argument to `add_shortcut`."
73 ]
74 },
75 {
76 "cell_type": "code",
77 "collapsed": false,
78 "input": [
79 "%%javascript\n",
80 "\n",
81 "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', function (event) {\n",
82 " IPython.notebook.execute_cell();\n",
83 " return false;\n",
84 "});"
85 ],
86 "language": "python",
87 "metadata": {},
88 "outputs": [
89 {
90 "javascript": [
91 "\n",
92 "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', function (event) {\n",
93 " IPython.notebook.execute_cell();\n",
94 " return false;\n",
95 "});"
96 ],
97 "metadata": {},
98 "output_type": "display_data",
99 "text": [
100 "<IPython.core.display.Javascript at 0x1019baf90>"
101 ]
102 }
103 ],
104 "prompt_number": 11
105 },
106 {
107 "cell_type": "markdown",
108 "metadata": {},
109 "source": [
110 "Likewise, to remove a shortcut, use `remove_shortcut`:"
111 ]
112 },
113 {
114 "cell_type": "code",
115 "collapsed": false,
116 "input": [
117 "%%javascript\n",
118 "\n",
119 "IPython.keyboard_manager.command_shortcuts.remove_shortcut('r');"
120 ],
121 "language": "python",
122 "metadata": {},
123 "outputs": [
124 {
125 "javascript": [
126 "\n",
127 "IPython.keyboard_manager.command_shortcuts.remove_shortcut('r');"
128 ],
129 "metadata": {},
130 "output_type": "display_data",
131 "text": [
132 "<IPython.core.display.Javascript at 0x10e8d1950>"
133 ]
134 }
135 ],
136 "prompt_number": 8
137 },
138 {
139 "cell_type": "markdown",
140 "metadata": {},
141 "source": [
142 "If you want your keyboard shortcuts to be active for all of your notebooks, put the above API calls into your `<profile>/static/custom/custom.js` file."
143 ]
144 }
145 ],
146 "metadata": {}
147 }
148 ]
9 } No newline at end of file
149 }
@@ -1,7 +1,7 b''
1 {
1 {
2 "metadata": {
2 "metadata": {
3 "name": "",
3 "name": "",
4 "signature": "sha256:f3479d16d8a60d0aa82e5fbffd52552e5649074a7a660730ddca9d5b286692b2"
4 "signature": "sha256:33a14f36e4dad22b2fc23c59ce0e0ed96719007a09f616f240ed5f665e1b871f"
5 },
5 },
6 "nbformat": 3,
6 "nbformat": 3,
7 "nbformat_minor": 0,
7 "nbformat_minor": 0,
@@ -53,9 +53,11 b''
53 "* [Running the Notebook Server](Running the Notebook Server.ipynb)\n",
53 "* [Running the Notebook Server](Running the Notebook Server.ipynb)\n",
54 "* [Notebook Dashboard](Notebook Dashboard.ipynb)\n",
54 "* [Notebook Dashboard](Notebook Dashboard.ipynb)\n",
55 "* [Notebook User Interface](Notebook User Interface.ipynb)\n",
55 "* [Notebook User Interface](Notebook User Interface.ipynb)\n",
56 "* [Notebook Cell Types](Notebook Cell Types.ipynb)\n",
56 "* [Custom Keyboard Shortcuts](Custom Keyboard Shortcuts.ipynb)\n",
57 "* [Working With Code Cells](Working With Code Cells.ipynb)\n",
57 "* [Working With Code Cells](Working With Code Cells.ipynb)\n",
58 "* [Basic Output](Basic Output.ipynb)\n",
58 "* [Working With Markdown Cells](Working With Markdown Cells.ipynb)\n",
59 "* [Working With Markdown Cells](Working With Markdown Cells.ipynb)\n",
60 "* [JavaScript Notebook Extensions](JavaScript Notebook Extensions.ipynb)\n",
59 "* [Notebook Security](Notebook Security.ipynb)"
61 "* [Notebook Security](Notebook Security.ipynb)"
60 ]
62 ]
61 },
63 },
@@ -71,19 +73,10 b''
71 "cell_type": "markdown",
73 "cell_type": "markdown",
72 "metadata": {},
74 "metadata": {},
73 "source": [
75 "source": [
74 "* [Custom Keyboard Shortcuts](Custom Keyboard Shortcuts.ipynb)\n",
75 "* [Importing Notebooks](Importing Notebooks.ipynb)\n",
76 "* [Importing Notebooks](Importing Notebooks.ipynb)\n",
76 "* [Connecting with the Qt Console](Connecting with the Qt Console.ipynb)\n",
77 "* [Connecting with the Qt Console](Connecting with the Qt Console.ipynb)\n",
77 "* [Typesetting Equations](Typesetting Equations.ipynb)"
78 "* [Typesetting Equations](Typesetting Equations.ipynb)"
78 ]
79 ]
79 },
80 {
81 "cell_type": "code",
82 "collapsed": false,
83 "input": [],
84 "language": "python",
85 "metadata": {},
86 "outputs": []
87 }
80 }
88 ],
81 ],
89 "metadata": {}
82 "metadata": {}
@@ -1,6 +1,7 b''
1 {
1 {
2 "metadata": {
2 "metadata": {
3 "name": ""
3 "name": "",
4 "signature": "sha256:fdeb47a733910a12406e6a2e4f13c2c76fe50b19428feb6ba77c06652fb1d6af"
4 },
5 },
5 "nbformat": 3,
6 "nbformat": 3,
6 "nbformat_minor": 0,
7 "nbformat_minor": 0,
@@ -12,235 +13,159 b''
12 "level": 1,
13 "level": 1,
13 "metadata": {},
14 "metadata": {},
14 "source": [
15 "source": [
15 "User Interface"
16 "Notebook User Interface"
16 ]
17 ]
17 },
18 },
18 {
19 {
19 "cell_type": "markdown",
20 "cell_type": "markdown",
20 "metadata": {},
21 "metadata": {},
21 "source": [
22 "source": [
22 "This notebook describes the user interface of the IPython Notebook. This includes both mouse and keyboard based navigation and interaction.\n",
23 "This notebook describes the user interface of the IPython Notebook. This includes both mouse and keyboard based navigation and interaction."
23 "\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",
26 "</div>"
27 ]
28 },
29 {
30 "cell_type": "heading",
31 "level": 2,
32 "metadata": {},
33 "source": [
34 "Modal editor"
35 ]
24 ]
36 },
25 },
37 {
26 {
38 "cell_type": "markdown",
27 "cell_type": "markdown",
39 "metadata": {},
28 "metadata": {},
40 "source": [
29 "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."
30 "<div class=\"alert\">\n",
31 "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",
32 "</div>"
42 ]
33 ]
43 },
34 },
44 {
35 {
45 "cell_type": "heading",
36 "cell_type": "heading",
46 "level": 3,
37 "level": 2,
47 "metadata": {},
38 "metadata": {},
48 "source": [
39 "source": [
49 "Edit mode"
40 "Overview of the UI"
50 ]
41 ]
51 },
42 },
52 {
43 {
53 "cell_type": "markdown",
44 "cell_type": "markdown",
54 "metadata": {},
45 "metadata": {},
55 "source": [
46 "source": [
56 "Edit mode is indicated by a green cell border and a prompt showing in the editor area:\n",
47 "The notebook UI has the following main areas:\n",
57 "\n",
58 "<img src=\"images/edit_mode.png\">\n",
59 "\n",
48 "\n",
60 "When a cell is in edit mode, you can type into the cell, like a normal text editor.\n",
49 "* Menu\n",
50 "* Toolbar\n",
51 "* Notebook area and cells\n",
61 "\n",
52 "\n",
62 "<div class=\"alert alert-success\" style=\"margin: 10px\">\n",
53 "IPython 2.0 has an interactive tour of these elements that can be started in the \"Help:User Interface Tour\" menu item."
63 "Enter edit mode by pressing `enter` or using the mouse to click on a cell's editor area.\n",
64 "</div>"
65 ]
54 ]
66 },
55 },
67 {
56 {
68 "cell_type": "heading",
57 "cell_type": "heading",
69 "level": 3,
58 "level": 2,
70 "metadata": {},
59 "metadata": {},
71 "source": [
60 "source": [
72 "Command mode"
61 "Modal editor"
73 ]
62 ]
74 },
63 },
75 {
64 {
76 "cell_type": "markdown",
65 "cell_type": "markdown",
77 "metadata": {},
66 "metadata": {},
78 "source": [
67 "source": [
79 "Command mode is indicated by a grey cell border:\n",
68 "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."
80 "\n",
81 "<img src=\"images/command_mode.png\">\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",
84 "\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",
87 "</div>\n",
88 "\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",
91 "</div>"
92 ]
69 ]
93 },
70 },
94 {
71 {
95 "cell_type": "heading",
72 "cell_type": "heading",
96 "level": 2,
73 "level": 3,
97 "metadata": {},
74 "metadata": {},
98 "source": [
75 "source": [
99 "Mouse navigation"
76 "Edit mode"
100 ]
77 ]
101 },
78 },
102 {
79 {
103 "cell_type": "markdown",
80 "cell_type": "markdown",
104 "metadata": {},
81 "metadata": {},
105 "source": [
82 "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",
83 "Edit mode is indicated by a green cell border and a prompt showing in the editor area:\n",
107 "\n",
84 "\n",
108 "<img src=\"images/menubar_toolbar.png\">"
85 "<img src=\"images/edit_mode.png\">\n",
109 ]
110 },
111 {
112 "cell_type": "markdown",
113 "metadata": {},
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",
116 "\n",
86 "\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."
87 "When a cell is in edit mode, you can type into the cell, like a normal text editor."
118 ]
88 ]
119 },
89 },
120 {
90 {
121 "cell_type": "markdown",
91 "cell_type": "markdown",
122 "metadata": {},
92 "metadata": {},
123 "source": [
93 "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",
94 "<div class=\"alert alert-success\">\n",
125 "\n",
95 "Enter edit mode by pressing `Enter` or using the mouse to click on a cell's editor area.\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."
96 "</div>"
127 ]
97 ]
128 },
98 },
129 {
99 {
130 "cell_type": "heading",
100 "cell_type": "heading",
131 "level": 2,
101 "level": 3,
132 "metadata": {},
102 "metadata": {},
133 "source": [
103 "source": [
134 "Keyboard Navigation"
104 "Command mode"
135 ]
105 ]
136 },
106 },
137 {
107 {
138 "cell_type": "markdown",
108 "cell_type": "markdown",
139 "metadata": {},
109 "metadata": {},
140 "source": [
110 "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",
111 "Command mode is indicated by a grey cell border:\n",
142 "\n",
112 "\n",
143 "The most important keyboard shortcuts are `enter`, which enters edit mode, and `esc`, which enters command mode.\n",
113 "<img src=\"images/command_mode.png\">\n",
144 "\n",
114 "\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:"
115 "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."
146 ]
116 ]
147 },
117 },
148 {
118 {
149 "cell_type": "markdown",
119 "cell_type": "markdown",
150 "metadata": {},
120 "metadata": {},
151 "source": [
121 "source": [
152 "The `display_edit_shortcuts()` function used here is defined in the [Utilities section](#Utilities) at the bottom of this notebook."
122 "<div class=\"alert alert-error\">\n",
123 "Don't try to type into a cell in command mode; unexpected things will happen!\n",
124 "</div>"
153 ]
125 ]
154 },
126 },
155 {
127 {
156 "cell_type": "code",
128 "cell_type": "markdown",
157 "collapsed": false,
158 "input": [
159 "display_edit_shortcuts()"
160 ],
161 "language": "python",
162 "metadata": {},
129 "metadata": {},
163 "outputs": [
130 "source": [
164 {
131 "<div class=\"alert alert-success\">\n",
165 "html": [
132 "Enter command mode by pressing `Esc` or using the mouse to click *outside* a cell's editor area.\n",
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>"
133 "</div>"
167 ],
134 ]
168 "output_type": "display_data"
169 },
135 },
170 {
136 {
171 "javascript": [
137 "cell_type": "heading",
172 "var help = IPython.quick_help.build_edit_help();\n",
138 "level": 2,
173 "help.children().first().remove();\n",
174 "this.append_output({output_type: 'display_data', html: help.html()});"
175 ],
176 "metadata": {},
139 "metadata": {},
177 "output_type": "display_data",
140 "source": [
178 "text": [
141 "Mouse navigation"
179 "<IPython.core.display.Javascript at 0x10e8d1a50>"
180 ]
142 ]
181 }
182 ],
183 "prompt_number": 17
184 },
143 },
185 {
144 {
186 "cell_type": "markdown",
145 "cell_type": "markdown",
187 "metadata": {},
146 "metadata": {},
188 "source": [
147 "source": [
189 "There are two other keyboard shortcuts in edit mode that are not listed here:\n",
148 "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",
190 "\n",
149 "\n",
191 "* `tab`: trigger \"tab\" completion\n",
150 "<img src=\"images/menubar_toolbar.png\">"
192 "* `shift+tab`: open the tooltip"
193 ]
151 ]
194 },
152 },
195 {
153 {
196 "cell_type": "markdown",
154 "cell_type": "markdown",
197 "metadata": {},
155 "metadata": {},
198 "source": [
156 "source": [
199 "In command mode, the entire keyboard is available for shortcuts:"
157 "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",
200 ]
158 "\n",
201 },
159 "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."
202 {
203 "cell_type": "code",
204 "collapsed": false,
205 "input": [
206 "display_command_shortcuts()"
207 ],
208 "language": "python",
209 "metadata": {},
210 "outputs": [
211 {
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>"
214 ],
215 "output_type": "display_data"
216 },
217 {
218 "javascript": [
219 "var help = IPython.quick_help.build_command_help();\n",
220 "help.children().first().remove();\n",
221 "this.append_output({output_type: 'display_data', html: help.html()});"
222 ],
223 "metadata": {},
224 "output_type": "display_data",
225 "text": [
226 "<IPython.core.display.Javascript at 0x10e8d1650>"
227 ]
160 ]
228 }
229 ],
230 "prompt_number": 18
231 },
161 },
232 {
162 {
233 "cell_type": "markdown",
163 "cell_type": "markdown",
234 "metadata": {},
164 "metadata": {},
235 "source": [
165 "source": [
236 "Here the rough order in which we recommend learning the command mode shortcuts:\n",
166 "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 <button><i class=\"icon-play\"></i></button> button in the toolbar or the \"Cell:Run\" menu item. Similarly, to copy a cell you would select it and click the <button><i class=\"icon-copy\"></i></button> 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",
237 "\n",
167 "\n",
238 "1. Basic navigation: `enter`, `shift-enter`, `up/k`, `down/j`\n",
168 "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 <button><i class=\"icon-play\"></i></button> button in the toolbar or the \"Cell:Run\" menu item. To unrender the selected cell, double click on the cell."
239 "2. Saving the notebook: `s`\n",
240 "2. Cell types: `y`, `m`, `1-6`, `t`\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",
243 "5. Kernel operations: `i`, `.`"
244 ]
169 ]
245 },
170 },
246 {
171 {
@@ -248,134 +173,43 b''
248 "level": 2,
173 "level": 2,
249 "metadata": {},
174 "metadata": {},
250 "source": [
175 "source": [
251 "Keyboard shortcut customization"
176 "Keyboard Navigation"
252 ]
177 ]
253 },
178 },
254 {
179 {
255 "cell_type": "markdown",
180 "cell_type": "markdown",
256 "metadata": {},
181 "metadata": {},
257 "source": [
182 "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:"
183 "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",
259 ]
260 },
261 {
262 "cell_type": "code",
263 "collapsed": false,
264 "input": [
265 "%%javascript\n",
266 "\n",
184 "\n",
267 "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', {\n",
185 "The most important keyboard shortcuts are `Enter`, which enters edit mode, and `Esc`, which enters command mode.\n",
268 " help : 'run cell',\n",
269 " help_index : 'zz',\n",
270 " handler : function (event) {\n",
271 " IPython.notebook.execute_cell();\n",
272 " return false;\n",
273 " }}\n",
274 ");"
275 ],
276 "language": "python",
277 "metadata": {},
278 "outputs": [
279 {
280 "javascript": [
281 "\n",
186 "\n",
282 "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', {\n",
187 "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:\n",
283 " help : 'run cell',\n",
284 " help_index : 'zz',\n",
285 " handler : function (event) {\n",
286 " IPython.notebook.execute_cell();\n",
287 " return false;\n",
288 " }}\n",
289 ");"
290 ],
291 "metadata": {},
292 "output_type": "display_data",
293 "text": [
294 "<IPython.core.display.Javascript at 0x10e8d1890>"
295 ]
296 }
297 ],
298 "prompt_number": 7
299 },
300 {
301 "cell_type": "markdown",
302 "metadata": {},
303 "source": [
304 "There are a couple of points to mention about this API:\n",
305 "\n",
188 "\n",
306 "* The `help_index` field is used to sort the shortcuts in the Keyboard Shortcuts help dialog. It defaults to `zz`.\n",
189 "<img src=\"images/edit_shortcuts.png\">"
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`."
309 ]
190 ]
310 },
191 },
311 {
192 {
312 "cell_type": "code",
313 "collapsed": false,
314 "input": [
315 "%%javascript\n",
316 "\n",
317 "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', function (event) {\n",
318 " IPython.notebook.execute_cell();\n",
319 " return false;\n",
320 "});"
321 ],
322 "language": "python",
323 "metadata": {},
324 "outputs": [
325 {
326 "javascript": [
327 "\n",
328 "IPython.keyboard_manager.command_shortcuts.add_shortcut('r', function (event) {\n",
329 " IPython.notebook.execute_cell();\n",
330 " return false;\n",
331 "});"
332 ],
333 "metadata": {},
334 "output_type": "display_data",
335 "text": [
336 "<IPython.core.display.Javascript at 0x1019baf90>"
337 ]
338 }
339 ],
340 "prompt_number": 11
341 },
342 {
343 "cell_type": "markdown",
193 "cell_type": "markdown",
344 "metadata": {},
194 "metadata": {},
345 "source": [
195 "source": [
346 "Likewise, to remove a shortcut, use `remove_shortcut`:"
196 "In command mode, the entire keyboard is available for shortcuts, so there are many more:\n",
347 ]
348 },
349 {
350 "cell_type": "code",
351 "collapsed": false,
352 "input": [
353 "%%javascript\n",
354 "\n",
355 "IPython.keyboard_manager.command_shortcuts.remove_shortcut('r');"
356 ],
357 "language": "python",
358 "metadata": {},
359 "outputs": [
360 {
361 "javascript": [
362 "\n",
197 "\n",
363 "IPython.keyboard_manager.command_shortcuts.remove_shortcut('r');"
198 "<img src=\"images/command_shortcuts.png\">"
364 ],
365 "metadata": {},
366 "output_type": "display_data",
367 "text": [
368 "<IPython.core.display.Javascript at 0x10e8d1950>"
369 ]
199 ]
370 }
371 ],
372 "prompt_number": 8
373 },
200 },
374 {
201 {
375 "cell_type": "markdown",
202 "cell_type": "markdown",
376 "metadata": {},
203 "metadata": {},
377 "source": [
204 "source": [
378 "If you want your keyboard shortcuts to be active for all of your notebooks, put the above API calls into your `<profile>/static/custom/custom.js` file."
205 "We recommend learning the command mode shortcuts in the following rough order:\n",
206 "\n",
207 "1. Basic navigation: `enter`, `shift-enter`, `up/k`, `down/j`\n",
208 "2. Saving the notebook: `s`\n",
209 "2. Cell types: `y`, `m`, `1-6`, `t`\n",
210 "3. Cell creation and movement: `a`, `b`, `ctrl+k`, `ctrl+j`\n",
211 "4. Cell editing: `x`, `c`, `v`, `d`, `z`, `shift+=`\n",
212 "5. Kernel operations: `i`, `.`"
379 ]
213 ]
380 },
214 },
381 {
215 {
@@ -383,62 +217,27 b''
383 "level": 2,
217 "level": 2,
384 "metadata": {},
218 "metadata": {},
385 "source": [
219 "source": [
386 "Utilities"
220 "Cell types"
387 ]
221 ]
388 },
222 },
389 {
223 {
390 "cell_type": "markdown",
224 "cell_type": "markdown",
391 "metadata": {},
225 "metadata": {},
392 "source": [
226 "source": [
393 "We use the following functions to generate the keyboard shortcut listings above."
227 "The notebook UI and notebook documents are a linear sequence of cells. There are four cell types:\n",
394 ]
395 },
396 {
397 "cell_type": "code",
398 "collapsed": false,
399 "input": [
400 "from IPython.display import Javascript, display, HTML\n",
401 "\n",
228 "\n",
402 "t = \"\"\"var help = IPython.quick_help.build_{0}_help();\n",
229 "* **Code cells:** Input and output of live code that is run in the kernel\n",
403 "help.children().first().remove();\n",
230 "* **Markdown cells:** Narrative text with embedded LaTeX equations\n",
404 "this.append_output({{output_type: 'display_data', html: help.html()}});\"\"\"\n",
231 "* **Heading cells:** 6 levels of hierarchical organization and formatting\n",
232 "* **Raw cells:** Unformatted text that is included, without modification, when notebooks are converted to different formats using nbconvert\n",
405 "\n",
233 "\n",
406 "def display_command_shortcuts():\n",
234 "More information about code and Markdown cell can be found in these tutorials:\n",
407 " display(Javascript(t.format('command')))\n",
408 "\n",
235 "\n",
409 "def display_edit_shortcuts():\n",
236 "* [Working With Code Cells](Working With Code Cells.ipynb)\n",
410 " display(Javascript(t.format('edit')))\n",
237 "* [Working With Markdown Cells](Working With Markdown Cells.ipynb)"
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 "\"\"\"))"
419 ],
420 "language": "python",
421 "metadata": {},
422 "outputs": [
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 ]
238 ]
437 }
239 }
438 ],
240 ],
439 "prompt_number": 16
440 }
441 ],
442 "metadata": {}
241 "metadata": {}
443 }
242 }
444 ]
243 ]
@@ -1,7 +1,7 b''
1 {
1 {
2 "metadata": {
2 "metadata": {
3 "name": "",
3 "name": "",
4 "signature": "sha256:3676a017d63581291cf2d61ea56d09cb3e5480a4f222184d8216e3e829eb4871"
4 "signature": "sha256:1fd1c67d342de34c5edf43789ce56f80963eda3662752e7d9cbc97ac54848be8"
5 },
5 },
6 "nbformat": 3,
6 "nbformat": 3,
7 "nbformat_minor": 0,
7 "nbformat_minor": 0,
@@ -112,7 +112,7 b''
112 "\n",
112 "\n",
113 "* **Code cells:** Input and output of live code that is run in the kernel\n",
113 "* **Code cells:** Input and output of live code that is run in the kernel\n",
114 "* **Markdown cells:** Narrative text with embedded LaTeX equations\n",
114 "* **Markdown cells:** Narrative text with embedded LaTeX equations\n",
115 "* **Heading cells:** 6 levels of hierarchical organization\n",
115 "* **Heading cells:** 6 levels of hierarchical organization and formatting\n",
116 "* **Raw cells:** Unformatted text that is included, without modification, when notebooks are converted to different formats using nbconvert\n",
116 "* **Raw cells:** Unformatted text that is included, without modification, when notebooks are converted to different formats using nbconvert\n",
117 "\n",
117 "\n",
118 "Internally, notebook documents are [JSON](http://en.wikipedia.org/wiki/JSO) data with binary values [base64](http://en.wikipedia.org/wiki/Base64) encoded. This allows them to be read and manipulated programmatically by any programming language. Because JSON is a text format, notebook documents are version control friendly.\n",
118 "Internally, notebook documents are [JSON](http://en.wikipedia.org/wiki/JSO) data with binary values [base64](http://en.wikipedia.org/wiki/Base64) encoded. This allows them to be read and manipulated programmatically by any programming language. Because JSON is a text format, notebook documents are version control friendly.\n",
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now