You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何设置Jupyter Notebook运行单元格后默认进入编辑模式?

Adjust Jupyter Notebook's Shift+Return to Enter Edit Mode Below

Absolutely, you can tweak this setting to make Shift+Return drop you straight into edit mode in the next cell—no extra clicks needed! Here are two straightforward ways to do it:

Method 1: Use the GUI Shortcut Editor (Easiest)

  • Open your Jupyter Notebook and switch to command mode (press Esc if you’re typing in a cell).
  • Click the Help menu at the top, then select Edit Keyboard Shortcuts. This opens a panel for customizing key bindings.
  • In the search bar, type "run cell and select below"—this is the default action tied to Shift+Return.
  • Instead of modifying the existing action, let’s create a new custom one that does exactly what you want:
    1. Click the Add Shortcut button.
    2. In the "Action" field, paste this combined command:
      run-cell-and-select-next, enter-edit-mode
      
    3. Click the "Shortcut" field and press Shift+Return to assign this key combo.
    4. Hit Save to apply the change.

Now, when you press Shift+Return, it’ll run the current cell, jump to the next one, and immediately put you into edit mode—perfect!

Method 2: Edit the Custom JS File (For Advanced Users)

If the GUI method doesn’t work for your Jupyter version, you can modify the custom.js file directly:

  • Locate your Jupyter config directory (usually ~/.jupyter/custom/ on macOS/Linux, or C:\Users\YourName\.jupyter\custom\ on Windows).
  • Open custom.js in a text editor, and add this code:
    require(["base/js/namespace", "base/js/events"], function(Jupyter, events) {
        Jupyter.keyboard_manager.command_shortcuts.add_shortcut('shift-enter', {
            help : 'Run cell and enter edit mode in next cell',
            handler : function (event) {
                Jupyter.notebook.execute_cell_and_select_next();
                Jupyter.notebook.edit_mode();
                return false;
            }
        });
    });
    
  • Save the file and restart your Jupyter Notebook server for changes to take effect.

Either method should fix the behavior you’re frustrated with.

内容的提问来源于stack exchange,提问作者Greg

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 03:33:34