54

Does anyone know if there is a keyboard shortcut to toggle next / previous tabs in JupyterLab (if there is, how to do it)? or if we can customize keyboard shortcuts?

EDIT

This youtube shows how you can customize your keyboard shortcuts in JupyterLab. I tried it and it works for me.

wi3o
  • 1,467
  • 3
  • 17
  • 29

2 Answers2

87

If you click the "Tabs" menu in Jupyter Lab, the keyboard shortcut should be listed there.

example: On my macbook it is CTRL+SHIFT+[ or CTRL+SHIFT+]

jeschwar
  • 1,286
  • 7
  • 10
warvolin
  • 1,030
  • 6
  • 9
  • 3
    With non international keyboard layout this results in tab switching of the browser though. – linello Mar 22 '18 at 10:56
  • Mmm you @linello were probably searching for how to toggling cell output... It happened to me too. Just glanced until toogle in the tittle and assumed it was the only toggle keyboard shortcut that Jupyter Notebooks have but not Jupyter labs... – Martin Oct 20 '18 at 19:44
  • 1
    @linello I just gave an answer for other keyboards. Feedback two this answer for other keyboard layouts then the German is very welcome. – Thomas R Jan 25 '22 at 13:49
10

Answer for German - (and other non-international) keyboards:

Since the previous answer does not work on a German keyboard I describe the problem for this keyboard and then I describe a solution for this keyboard which shall work similarly on other keyboards as well.

1. Problem with current settings

"[" and "]" on an international keyboard are the two keys right of "p". On the German keyboard "ä" and "+". "ctrl shift ä" switches to the left/previous tab as expected. But "ctrl shift +" as well as "ctrl shift ]" does not switch to the next/right.

I tried almost every shortcut. But had to change the shortcuts themselves.

2. The problem of choosing a new shortcut

Since "ctrl shift ä" worked as expected I tried to change the other shortcut to "ctrl shift +". And since the other two assignments of the key "+" on a German Keyboard are "*" and "~" I tried "ctrl shift *" and "ctrl shift ~" as well.

After saving, all failed to work, when I tested them.

3. Solution

Here is a description of how to change the shortcuts in Jupyter Lab.

I chose the shortcuts "Ctrl Shift 8" and "Ctrl Shift 9" since “8” and “9” are on the same keys as “[“ and “]”. Then you have to enter the following code as described in the link above.

Steps:
In Jupyter-Lab:

  1. "settings"
  2. "Advanced Settings Editor"
  3. "Keyboard Shortcuts"
  4. In the now appearing field "User Preferences", if empty: copy the following dictionary. If the field is not empty add or adapt the key "shortcuts" accordingly:

_

{
  "shortcuts": [
        {
            "command": "application:activate-previous-tab",
            "keys": [
                "Ctrl Shift 8"
            ],
            "selector": "body"
        },
        {"command": "application:activate-next-tab",
            "keys": [
                "Ctrl Shift 9"
            ],
            "selector": "body"
        }
  ]
}
Thomas R
  • 1,067
  • 11
  • 17