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

Jupyter中如何跳转到最后编辑的单元格(优先快捷键方式)?

Hey there, great question—jumping back to your last edited cell is way more straightforward than hunting through Markdown blocks once you know the right tricks! Here are your best options, with shortcuts as the top priority:

Jump to the Last Edited Cell in Jupyter Notebook/Lab

1. Use the Native Command Panel (No Extensions Needed)

This works for both classic Jupyter Notebook and Jupyter Lab, and it's the quickest built-in solution:

  • Press Ctrl+Shift+P (Windows/Linux) or Cmd+Shift+P (Mac) to open the Command Palette.
  • Type "Last Edited Cell" (or just "last edit" to narrow results fast).
  • Select the "Go to Last Edited Cell" command, and you’ll jump straight to the last cell you were editing.

For Jupyter Lab users, you can even bind a permanent custom shortcut:

  • Go to Settings > Keyboard Shortcuts.
  • Search for "last edited cell".
  • Click the pencil icon next to the command and set your preferred shortcut (e.g., Ctrl+Shift+E).

2. Jupyter Notebook Extensions (Classic Notebook)

If you’re using the classic Jupyter Notebook (not Lab) and already have the Jupyter Notebook Extensions (nbextensions) installed:

  • Open the nbextensions tab (usually at the top of your Notebook dashboard).
  • Look for the "Jump to last edit cell" extension and enable it.
  • Once enabled, configure a custom shortcut in the extension’s settings (pick something that doesn’t clash with existing shortcuts, like Alt+L).

3. Custom JavaScript Script (Advanced)

If you want full control and don’t want to rely on extensions, add a custom script to your Jupyter config:

  1. Navigate to your Jupyter custom directory (usually ~/.jupyter/custom/ on Linux/Mac, or %USERPROFILE%\.jupyter\custom\ on Windows).
  2. Create or edit the custom.js file and add this code:
require(['base/js/namespace', 'base/js/events'], function(Jupyter, events) {
    let lastEditedCell = null;

    // Track when a cell enters edit mode
    events.on('edit_mode.Cell', function(event, data) {
        lastEditedCell = data.cell;
    });

    // Bind a shortcut to jump to the last edited cell
    Jupyter.keyboard_manager.command_shortcuts.add_shortcut('Ctrl+Shift+E', {
        help: 'Jump to last edited cell',
        handler: function() {
            if (lastEditedCell) {
                lastEditedCell.focus_cell();
                Jupyter.notebook.select(lastEditedCell);
            }
            return false;
        }
    });
});
  1. Restart your Jupyter Notebook server, and you can now use Ctrl+Shift+E (or whatever shortcut you set) to jump back instantly.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 07:20:14