Jupyter Notebook编辑器有两种不同的键盘输入模式。即命令模式和编辑模式,这与 Vim 有些类似。在编辑模式下,可以在单元格中输入代码或文本,此时单元格被绿色的框线包围,且命令模式下的快捷键不生效。在命令模式下,可以用快捷键命令运行单元格,移动单元格,切换单元格编辑状态等等,此时的单元格被灰色的框线包围,且编辑模式下的快捷键不生效。
命令模式(按 Esc 生效)
快捷键
说明1
说明2
F
find and replace
查找并且替换
Ctrl-Shift-F
open the command palette
打开命令配置
Ctrl-Shift-P
open the command palette
打开命令配置
Enter
enter edit mode
进入编辑模式
P
open the command palette
打开命令配置
Shift-Enter
run cell, select below
运行代码块, 选择下面的代码块
Ctrl-Enter
run selected cells
运行选中的代码块
Alt-Enter
run cell and insert below
运行代码块并且在下面插入代码块
Y
change cell to code
把代码块变成代码
M
change cell to markdown
把代码块变成 Markdown
R
change cell to raw
清除代码块格式
1
change cell to heading 1
把代码块变成标题 1
2
change cell to heading 2
把代码块变成标题 2
3
change cell to heading 3
把代码块变成标题 3
4
change cell to heading 4
把代码块变成标题 4
5
change cell to heading 5
把代码块变成标题 5
6
change cell to heading 6
把代码块变成标题 6
K
select cell above
选择上面的代码块
上
select cell above
选择上面的代码块
下
select cell below
选择下面的代码块
J
select cell below
选择下面的代码块
Shift-K
extend selected cells above
扩展上面选择的代码块
Shift-上
extend selected cells above
扩展上面选择的代码块
Shift-下
extend selected cells below
扩展下面选择的代码块
Shift-J
extend selected cells below
扩展下面选择的代码块
Ctrl-A
select all cells
select all cells
A
insert cell above
在上面插入代码块
B
insert cell below
在下面插入代码块
X
cut selected cells
剪切选择的代码块
C
copy selected cells
复制选择的代码块
Shift-V
paste cells above
粘贴到上面
V
paste cells below
粘贴到下面
Z
undo cell deletion
撤销删除
D,D
delete selected cells
删除选中单元格
Shift-M
merge selected cells, or current cell with cell below if only one cell is selected
合并选中单元格, 如果只有一个单元格被选中
Ctrl-S
Save and Checkpoint
保存并建立检查点
S
Save and Checkpoint
保存并建立检查点
L
toggle line numbers
切换行号
O
toggle output of selected cells
切换选定单元格的输出
Shift-O
toggle output scrolling of selected cells
切换选中单元格的输出滚动
H
show keyboard shortcuts
显示键盘快捷键
I,I
interrupt the kernel
中断内核
0,0
restart the kernel (with dialog)
重启内核(带确认对话框)
Esc
close the pager
关闭分页器
Q
close the pager
关闭分页器
Shift-L
toggles line numbers in all cells, and persist the setting