Jupyter cell move shortcut

Jupyter Lab doesn't have shortcut keys to move cells up and down. Also, since the operation with the mouse was complicated, I made my own shortcut key. I will write it down as a memorandum.

Setting method

  1. Launch Jupyter Lab.
  2. Open Settings-> Advanced Settings Editor.
  3. Select Keyboard Shortcuts, enter the following in ʻUser Preferences` on the right and save.

UserPreferences


{
    "shortcuts": [
        {
            "command": "notebook:move-cell-up",
            "keys": [
                "Ctrl Shift K"
            ],
            "selector": ".jp-Notebook:focus"
        
        },
        {
            "command": "notebook:move-cell-down",
            "keys": [
                "Ctrl Shift J"
            ],
            "selector": ".jp-Notebook:focus"
        
        },
    ]
}

You can now use Ctrl Shift K to move the cell up and Ctrl Shift J to move the cell down while in cell mode.

Description

Since the shortcut key to select the upper (lower) cell of the selected cell with Ctrl K (Ctrl J) was assigned, this shortcut was changed to Ctrl Shift K (Ctrl Shift J). ..

If you want to create other shortcut keys, you can find out by searching for System Defaults.

Other settings

Line number setting

By the way, displaying the line number can be set in the same way. Enter the following in ʻUser Preferences of Settings-> Advanced Settings Editor-> Notebook` and save.

UserPreferences


{
    "codeCellConfig":{
        "lineNumbers": true,
    },
}

Recommended Posts

Jupyter cell move shortcut
[Complete version] Jupyter Notebook shortcut
Use markdown with jupyter notebook (with shortcut)
Jupyter Notebook basic operations and shortcut keys
Rich cell output with Jupyter Notebook (IPython)