一. Jupyter notebook的兩種模式
- 命令模式

命令模式
- 編輯模式

編輯模式
- 如何切換模式?
從編輯模式切換到命令模式:在Jupyter notebook下,按ESC即可
從命令模式切換到編輯模式:在Jupyter notebook下,按ENTER即可 ; 或者將鼠標(biāo)放在編輯欄,點(diǎn)鼠標(biāo)左鍵
二.系統(tǒng)自帶的快捷鍵
- 只需要在命令模式下按 h 鍵即可,效果如下(如果懶得自己去翻譯,后面會給出每個快捷鍵的翻譯,效果可以自己去嘗試):

系統(tǒng)快捷鍵
三.自己設(shè)置快捷鍵
- 只需要先按ESC+h進(jìn)入快捷鍵頁面,然后點(diǎn)擊Edit Shortcuts

快捷鍵設(shè)置
四.命令模式(按ESC進(jìn)入)
- F: find and replace
查找并替換 - Ctrl-Shift-F: open the command palette
打開命令控制面板 - Ctrl-Shift-P: open the command palette
打開命令控制面板 - Enter: enter edit mode
進(jìn)入編輯模式 - P: open the command palette
打開命令控制面板 - Shift-Enter: run cell, select below
運(yùn)行單元,選擇下個單元 - Ctrl-Enter: run selected cells
運(yùn)行當(dāng)前選中的單元 - Alt-Enter: run cell and insert below
運(yùn)行單元,插入下一個單元 - Y: change cell to code
切換到代碼模式 - M: change cell to markdown
切換到Markdown模式 - R: change cell to raw
切換到Row NBConvert模式(這時代碼無法運(yùn)行,需要按ESC+Y進(jìn)入代碼模式) - 1: change cell to heading 1
切換至一級標(biāo)題 - 2: change cell to heading 2
切換至二級標(biāo)題 - 3: change cell to heading 3
切換至三級標(biāo)題 - 4: change cell to heading 4
切換至四級標(biāo)題 - 5: change cell to heading 5
切換至五級標(biāo)題 - 6: change cell to heading 6
切換至六級標(biāo)題 - K: select cell above
選中上方單元 - Up: select cell above
選中上方單元 - Down: select cell below
選中下方單元 - J: select cell below
選中下方單元 - Shift-K: extend selected cells above
擴(kuò)充選中上方單元(此時包含本單元) - Shift-Up: extend selected cells above
擴(kuò)充選中上方單元(此時包含本單元) - Shift-Down: extend selected cells below
擴(kuò)充選中下方單元(此時包含本單元) - Shift-J: extend selected cells below
擴(kuò)充選中下方單元(此時包含本單元) - Ctrl-A: select all cells
選擇所有單元 - A: insert cell above
在上方插入單元 - B: insert cell below
在下方插入單元 - X: cut selected cells
剪切選中的單元 - C: copy selected cells
復(fù)制選中的單元 - Shift-: paste cells above
黏貼到上方單元 - V: paste cells below
黏貼到下方單元 - Z: undo cell deletion
恢復(fù)刪除的最后一個單元 - D,D: delete selected cells
刪除選中的單元 - Shift-M: merge selected cells, or current cell with cell below if only one cell is selected
合并選定的單元格,如果只選擇一個單元格,則將當(dāng)前單元格與下面的單元格合并 - Ctrl-S: Save and Checkpoint
保存文件 - S: Save and Checkpoint
保存文件 - L: toggle line numbers
轉(zhuǎn)換行號 - O: toggle output of selected cells
轉(zhuǎn)換輸出 - Shift-O: toggle output scrolling of selected cells
轉(zhuǎn)換輸出滾動 - H: show keyboard shortcuts
展示快捷鍵頁面 - I,I: interrupt the kernel
中斷內(nèi)核 - 0,0: restart the kernel (with dialog)
重啟內(nèi)核 - Esc: close the pager
關(guān)閉頁面 - Q: close the pager
關(guān)閉頁面 - Shift-L: toggles line numbers in all cells, and persist the setting
切換所有單元格中的行號,并保持設(shè)置不變 - Shift-Space: scroll notebook up
向上滾動 - Space: scroll notebook down
向下滾動
五.編輯模式(按Enter進(jìn)入)
- Tab: code completion or indent
代碼補(bǔ)全或縮進(jìn) - Shift-Tab: tooltip
提示 - Ctrl-]: indent
縮減 - Ctrl-[: dedent
取消縮進(jìn) - Ctrl-A: select all
全選 - Ctrl-Z: undo
復(fù)原 - Ctrl-/: comment
注釋單行 - Ctrl-D: delete whole line
刪除整行 - Ctrl-U: undo selection
取消選擇 - Ctrl-Home: go to cell start
跳到單元頭 - Ctrl-Up: go to cell start
跳到單元頭 - Ctrl-End: go to cell end
跳到單元尾 - Ctrl-Down: go to cell end
跳到單元尾 - Ctrl-Left: go one word left
跳到左邊一個字首 - Ctrl-Right: go one word right
跳到右邊一個字首 - Ctrl-Backspace: delete word before
刪除前一個word - Ctrl-Delete: delete word after
刪除后一個word - Ctrl-Y: redo
重做 - Alt-U: redo selection
重做選擇 - Ctrl-M: enter command mode
進(jìn)入命令模式 - Ctrl-Shift-F: open the command palette
打開命令控制面板 - Ctrl-Shift-P: open the command palette
打開命令控制面板 - Esc: enter command mode
進(jìn)入命令模式 - Shift-Enter: run cell, select below
運(yùn)行單元,選擇下個單元 - Ctrl-Enter: run selected cells
運(yùn)行當(dāng)前選中的單元 - Alt-Enter: run cell and insert below
運(yùn)行單元,插入下一個單元 - Ctrl-Shift-Minus: split cell at cursor
在光標(biāo)處分割單元格 - Ctrl-S: Save and Checkpoint
保存文件 - Down: move cursor down
下移光標(biāo) - Up: move cursor up
上移光標(biāo)