在Colaboratory中使用Jupyter Notebook默认快捷键的方法咨询
Great questions—these are super common pain points when switching from Jupyter Notebook to Colab! Let’s break this down step by step.
Colab makes it pretty straightforward to switch to Jupyter's classic keybindings, no hacks required:
Use the Built-in Preset
- Click the gear icon ⚙️ in the top-right corner to open Colab's Settings.
- Navigate to the Keyboard shortcuts tab.
- At the top, you'll see a dropdown labeled "Keyboard shortcut scheme"—select Jupyter Notebook (legacy).
- Hit "Save", and you’re set! Most of Jupyter’s go-to shortcuts (like
bfor inserting a cell below,afor above,ddto delete a cell) will now work exactly like they do in regular Jupyter.
Tweak Custom Shortcuts (If Needed)
If a few shortcuts still don’t match your muscle memory, you can adjust them manually:- In the Keyboard shortcuts tab, use the search bar to find the action you want (e.g., "Insert cell below").
- Hover over the current shortcut, click the pencil icon ✏️, and press the key combination you prefer.
- Save your changes—Colab will remember these custom bindings for all your future sessions.
The issue where b and similar shortcuts don’t work usually boils down to Colab’s two modes—let’s clarify and fix this:
Master Command vs. Edit Mode
Colab (like Jupyter) has two distinct modes:- Command Mode: The cell has a blue border, no cursor inside. This is where all the cell-manipulation shortcuts (
b,a,dd) work. - Edit Mode: The cell has a green border, and you see a cursor inside—here, keystrokes type text into the cell.
If pressingbjust types a letter, you’re in Edit Mode! PressEscto switch back to Command Mode, andbwill instantly insert a new cell below.
- Command Mode: The cell has a blue border, no cursor inside. This is where all the cell-manipulation shortcuts (
Turn Off Editor Shortcut Overrides
Sometimes Colab’s editor settings can cause shortcuts to fire even when you’re in Edit Mode. To fix this:- Go back to the Keyboard shortcuts tab.
- Look for the setting labeled "Override command mode shortcuts in editor"—if it’s enabled, toggle it off.
This ensures that Command Mode shortcuts only trigger when you’re actually in Command Mode, eliminating accidental text input.
Use the Command Palette as a Safety Net
If you ever forget which mode you’re in, pressCtrl/Cmd + Shift + Pto open the Command Palette. You can search for any action (like "Insert cell below") and run it with a click—no shortcut required. It’s a great way to get things done while you’re getting used to the mode switch.
内容的提问来源于stack exchange,提问作者Daniel Lenz

