如何在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)
- 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) orCmd+,(Mac)
- 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" } } }
- 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+Clickto add multiple cursors orAlt+Dragfor column selection.
For Classic Jupyter Notebook (Legacy Interface)
If you're using the older classic Notebook interface:
- Open Preferences
- Click the Edit menu, then select Preferences
- 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!)
- 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
相关产品推荐
相关产品推荐

