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

如何在Jupyter Lab中实现多光标编辑?原Notebook用JS代码实现

How to Enable Sublime-Style Multi-Cursor Editing in Jupyter Notebook via Settings

Hey there! Great question—you absolutely can set up Sublime-style multi-cursor editing through Jupyter's built-in settings, no custom JS snippets required. Here's a straightforward, step-by-step guide:

For JupyterLab (Modern Interface)

  1. Open the Advanced Settings Editor
    • Click the Settings menu in the top-right corner, then select Advanced Settings Editor
    • Or use the keyboard shortcut: Ctrl+, (Windows/Linux) or Cmd+, (Mac)
  2. Configure the CodeMirror key map
    • In the left sidebar, select the Notebook category
    • Look for the User Preferences panel on the right (this is where you'll add your custom settings)
    • Paste the following JSON configuration into the panel:
      {
        "codeCellConfig": {
          "cmConfig": {
            "keyMap": "sublime"
          }
        }
      }
      
  3. Save and apply
    • Click the Save Settings button at the top of the editor (changes might auto-save in some versions)
    • Refresh your Notebook page, and you're all set! All new and existing code cells will use the Sublime key map, including multi-cursor features like Ctrl+Click to add multiple cursors or Alt+Drag for column selection.

For Classic Jupyter Notebook (Legacy Interface)

If you're using the older classic Notebook interface:

  1. Open Preferences
    • Click the Edit menu, then select Preferences
  2. Update CodeMirror settings
    • In the pop-up settings window, find the CodeMirror Options section
    • Add "keyMap": "sublime" to the existing JSON configuration (make sure the syntax is valid—commas matter!)
  3. Save and restart
    • Click Save to apply the changes, then restart your Notebook server for the settings to take effect.

Why This Is Better Than the Custom JS Snippet

This built-in setting is persistent—you won't need to re-run a code snippet every time you open a Notebook. It also applies globally to all cells and new Notebooks, so you don't have to manually update each cell like you did with the JS loop.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 08:12:12