1. 程式人生 > >Jupyter Notebook 快捷鍵和技巧

Jupyter Notebook 快捷鍵和技巧

pager scroll 補全 code only span 按鍵 whole 文檔

Jupyter Notebook 有兩種鍵盤輸入模式。

編輯模式,允許你往單元中鍵入代碼或文本,這時的單元框線是綠色的。

命令模式,鍵盤輸入運行程序命令;這時的單元框線是藍色

命令模式 (按鍵 Esc 開啟)

  • Enter : 轉入編輯模式
  • Shift-Enter : 運行本單元,選中下個單元
  • Ctrl-Enter : 運行本單元
  • Alt-Enter : 運行本單元,在其下插入新單元
  • Y : 單元轉入代碼狀態
  • M :單元轉入markdown狀態
  • R : 單元轉入raw狀態
  • 1 : 設定 1 級標題
  • 2 : 設定 2 級標題
  • 3 : 設定 3 級標題
  • 4 : 設定 4 級標題
  • 5 : 設定 5 級標題
  • 6 : 設定 6 級標題
  • Up : 選中上方單元
  • K : 選中上方單元
  • Down : 選中下方單元
  • J : 選中下方單元
  • Shift-K : 擴大選中上方單元
  • Shift-J : 擴大選中下方單元
  • A : 在上方插入新單元
  • B : 在下方插入新單元
  • X : 剪切選中的單元
  • C : 復制選中的單元
  • Shift-V : 粘貼到上方單元
  • V : 粘貼到下方單元
  • Z : 恢復刪除的最後一個單元
  • D,D : 刪除選中的單元
  • Shift-M : 合並選中的單元
  • Ctrl-S : 文件存盤
  • S : 文件存盤
  • L : 轉換行號
  • O : 轉換輸出
  • Shift-O : 轉換輸出滾動
  • Esc : 關閉頁面
  • Q : 關閉頁面
  • H : 顯示快捷鍵幫助
  • I,I : 中斷Notebook內核
  • 0,0 : 重啟Notebook內核
  • Shift : 忽略
  • Shift-Space : 向上滾動
  • Space : 向下滾動

編輯模式 ( Enter 鍵啟動)

  • Tab : 代碼補全或縮進
  • Shift-Tab : 提示
  • Ctrl-] : 縮進
  • Ctrl-[ : 解除縮進
  • Ctrl-A : 全選
  • Ctrl-Z : 復原
  • Ctrl-Shift-Z : 再做
  • Ctrl-Y : 再做
  • Ctrl-Home
    : 跳到單元開頭
  • Ctrl-Up : 跳到單元開頭
  • Ctrl-End : 跳到單元末尾
  • Ctrl-Down : 跳到單元末尾
  • Ctrl-Left : 跳到左邊一個字首
  • Ctrl-Right : 跳到右邊一個字首
  • Ctrl-Backspace : 刪除前面一個字
  • Ctrl-Delete : 刪除後面一個字
  • Esc : 進入命令模式
  • Ctrl-M : 進入命令模式
  • Shift-Enter : 運行本單元,選中下一單元
  • Ctrl-Enter : 運行本單元
  • Alt-Enter : 運行本單元,在下面插入一單元
  • Ctrl-Shift-- : 分割單元
  • Ctrl-Shift-Subtract : 分割單元
  • Ctrl-S : 文件存盤
  • Shift : 忽略
  • Up : 光標上移或轉入上一單元
  • Down :光標下移或轉入下一單元

HELP可以幫助我們直接進入對應的官方文檔

技術分享圖片

Keyboard Shortcuts 原文檔

The Jupyter Notebook has two different keyboard input modes. Edit mode allows you to type code or text into a cell and is indicated by a green cell border. Command mode binds the keyboard to notebook level commands and is indicated by a grey cell border with a blue left margin.

Command Mode (press Esc to enable)

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 R: change cell to raw 1: change cell to heading 1 2: change cell to heading 2 3: change cell to heading 3 4: change cell to heading 4 5: change cell to heading 5 6: change cell to heading 6 K: select cell above Up: select cell above Down: select cell below J: select cell below Shift-K: extend selected cells above Shift-Up: extend selected cells above Shift-Down: extend selected cells below Shift-J: extend selected cells below 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 Shift-Space: scroll notebook up Space: scroll notebook down

Edit Mode (press Enter to enable)

Tab: code completion or indent Shift-Tab: tooltip Ctrl-]: indent Ctrl-[: dedent Ctrl-A: select all Ctrl-Z: undo Ctrl-/: comment Ctrl-D: delete whole line Ctrl-U: undo selection Insert: toggle overwrite flag 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 Ctrl-Delete: delete word after Ctrl-Y: redo Alt-U: redo selection Ctrl-M: enter command mode Ctrl-Shift-F: open the command palette Ctrl-Shift-P: open the command palette Esc: enter command mode Shift-Enter: run cell, select below Ctrl-Enter: run selected cells Alt-Enter: run cell and insert below Ctrl-Shift-Minus: split cell at cursor Ctrl-S: Save and Checkpoint Down: move cursor down Up: move cursor up

Jupyter Notebook 快捷鍵和技巧