LoginSignup
6
3

More than 3 years have passed since last update.

Jupyter LABへのショートカットキーの割当て:Run Sellected Cell and All Below/Run All Cells

Last updated at Posted at 2020-04-25

背景

頻繁に使うことが多い、Run All Belowにショートカットキーが割り当てられていないので作成方法を探りました。

Run All Below ⇒   Command+Shit+Enter (好みで選択)

Jupyter Notebookでは簡単に作成出来るのですが、JupyterLabではそれほど簡単ではないです。
他のコマンドのキー割り当ても同様に出来ます。
慣れれば難しいものではないです。

追加

Run All Cells ⇒    Command+Option+Enter

参考文献

JupyterLABでのショートカット追加に関する記事

以下の2つのブログを参考にしました。
Jupyter Lab ショートカット一覧(Windows) とキー割り当て変更方法
Expose Run Selected Cell and All Below handle for keyboard shortcut creation#5371

Jupyter Notebookのショートカット変更方法

Notebookの方は簡単に作成出来ます。
Jupyter notebook ショートカット解説

【1】 変更する場所

メニューで
Setting -->Advanced Settings Editor-->New Notebook
を選択します。
System Defalutsに数多くのショートカットが表示されます。
CA080319-2C2D-4B84-9199-9FF468EBC776.png

【2】コードを記入

User Preferenceにコードを記入-->Saveボタン(右上の小さいボタン)
syntax Error等があると同じく右下に表示されるのでNo Errorが出るまでつぶします。
A1301911-8304-4C79-B789-8415CB3398D1.png
Run Selected Cell and All Belowの欄にショートカットキーが現れる(再起動は不要:そのまま出てくる)
B11728D3-8854-4A29-B5EA-8A726FCC5144.png
以下からコピペが出来ます。

{
    "shortcuts": [
        {
            "command": "notebook:run-all-below",
            "keys": [
                "Accel Shift Enter"
            ],
            "selector": ".jp-Notebook:focus"
        }
        ]

}

コードの詳細

"keys"

Accel (MacではCommandキー)
Accel Shift Enter
とそのまま打ち込む(Jupyter Notebookの様なハイフォン等は不要)

"command"と"selector"

他の似たようなショートカットキーをまねて入れます。
セレクターは正しく入れることが重要です。

【3】追加

Run All Cells

追加をする際には、カンマ(,)を入れるのがポイント
よく使う、run-all-cellsを入れてみました。MACのOption KeyはAlt

        },
        {
{
    "shortcuts": [
        {
            "command": "notebook:run-all-below",
            "keys": [
                "Accel Shift Enter"
            ],
            "selector": ".jp-Notebook:focus"
        },
        {
            "command": "notebook:run-all-cells",
            "keys": [
                "Accel Alt Enter"
            ],
            "selector": ".jp-Notebook:focus"
        }
        ]

}

以上

6
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
3